feat: exports マップ導入 + ESM 優先構成に刷新する (0.4.0)#18
Merged
Conversation
main/types が cjs 固定だったのを改め、exports フィールドで条件付き解決 (import→esm / require→cjs / types→esm) を定義する。subpath も 明示マップ (./esm, ./esm/*, ./cjs, ./cjs/*) し、既存 consumer の import パターンを全て維持する。bundler 向けに module フィールドも追加。 version を 0.4.0 へ。 検証: im-core を直接参照する 7 consumer (im-cmp / trust360 / livedoor-cdp-client / beacon.js / gpt-secure / im-uid-clients-livedoor) と imuid 経由 tsc の im-query-param で build/compile が全て成功する ことを node_modules 差し替えで確認済み。 注: esm/*.js は TS 出力が拡張子なし相対 import のため Node ネイティブ ESM では読めない (bundler 専用)。type:"module" を付与すると逆に Node ESM が壊れるため付けない。真の Node-ESM 対応はビルド改修が別途必要。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
単一 types (esm) だと require 解決時に CJS 実体へ ESM 版の型を当てる 形になり、attw 等が types/runtime のモジュール形式不一致を警告する。 import→esm/index.d.ts, require→cjs/index.d.ts と条件別に分け、 dual-package の型提供を by-the-book にする。 検証: im-cmp(webpack) / trust360(ts-loader) / im-query-param(tsc) で build/compile が引き続き成功。require→cjs / import→esm の Node 解決も確認。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
im-coreのパッケージ構成をexportsマップ + ESM 優先に刷新する。0.4.0 として publish する。#17 (types typo 修正・0.3.1) の続きで、main/typesが cjs 固定だった構成を現代化する。変更内容
exportsフィールドを導入し条件付き解決を定義.→import: esm/require: cjs/types: esm./esm,./esm/*→ esm(既存 consumer が使用)./cjs,./cjs/*→ cjs(require 系フォールバック)./package.jsonmoduleフィールド追加(bundler 向け esm ヒント)typesを./esm/index.d.tsにversion: 0.3.1 → 0.4.0既存 consumer の import パターン(bare
././esmバレル /./esm/XHR等)を全て維持する非破壊設計。検証
im-core を参照する全 consumer の node_modules を本ブランチの im-core で差し替え、build/compile が通ることを確認:
.(named)/esm/*型/esmバレル/esmバレル/esm/*/esm/*/esm/*im-core 自身:
pnpm build✅ /pnpm lint✅ /pnpm test51 passed ✅既知の制約
esm/*.jsは TS 出力が拡張子なし相対 import のため Node ネイティブ ESM では読めず bundler 専用。type:"module"を付けると逆に Node ESM がERR_MODULE_NOT_FOUNDで壊れるため付与しない。真の Node-ESM 対応は.js拡張子を出力するビルド改修が別途必要(フォローアップ)。マージ後
CI が 0.4.0 を publish。bare import で型の恩恵を受ける im-cmp を 0.4.0 へ更新(別 PR)。subpath のみの consumer は更新不要。
🤖 Generated with Claude Code