Skip to content

Fix published utils export#223

Open
jaasieldelgado131 wants to merge 1 commit into
theisel:mainfrom
jaasieldelgado131:fix-utils-published-js
Open

Fix published utils export#223
jaasieldelgado131 wants to merge 1 commit into
theisel:mainfrom
jaasieldelgado131:fix-utils-published-js

Conversation

@jaasieldelgado131

Copy link
Copy Markdown

Summary

  • point the published astro-portabletext/utils export at generated JavaScript instead of the TypeScript source file
  • add a package prepack build that emits the JS used by that subpath
  • update internal relative imports so the emitted ESM resolves in Node

Reproduction

With the published astro-portabletext@0.13.0 package:

mkdir repro && cd repro
npm init -y
npm install astro-portabletext@0.13.0
node --input-type=module -e "await import('astro-portabletext/utils')"

Node fails with ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING because the subpath resolves to lib/utils.ts under node_modules.

After this change, npm pack runs the package build and the packed tarball contains lib/utils.js, lib/context.js, and lib/internal.js; installing that tarball in a clean project allows import('astro-portabletext/utils') to succeed.

Validation

  • corepack pnpm --dir astro-portabletext build
  • corepack pnpm --dir astro-portabletext check
  • corepack pnpm --dir lab check
  • corepack pnpm --dir lab exec uvu -r tsm src/lib
  • corepack pnpm --dir lab build:fixture
  • corepack pnpm --dir lab exec uvu src/test .test.js
  • corepack pnpm lint
  • npm pack --json --pack-destination <temp> from astro-portabletext/, then clean install of the tarball and import('astro-portabletext/utils')

Note: pnpm test:ci is a shell wrapper (./scripts/ci.sh) and does not run directly in this Windows environment, so I ran the same underlying commands individually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant