-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pnp): experimental esm support (#2161)
* feat: esm support * fix: detect module type from any workspace * fix: always treat cjs as commonjs * test: add tests * chore: change loader name * test: exports * fix: use legacy resolve if exports is missing * chore: update config name * feat: enable loader if any package is a module * fix: use `findPnpApi` to get the correct `pnpapi` instance * fix: check if specifier has a pnpapi * ci: add SvelteKit test * ci: add Astro e2e test * fix: pass unknown extensions to the next loader * fix: don't enter ESM mode if main is cjs * fix: handle absolute paths to `_findPath` * chore: let node handle encoding the path to the loader * fix: get pnpapi of absolute path in `_findPath` * Update packages/yarnpkg-pnp/sources/esm-loader/loader.ts Co-authored-by: Maël Nison <nison.mael@gmail.com> * test: add dynamic import tests * test: check named exports from a zip file works * refactor: avoid code generation * test: skip `dynamic import in cjs` test * refactor: cleanup * refactor: rename config and move it to the plugin * fix: support explicitly disabling ESM support * chore: print a warning about experimental esm support * fix: make `isEsmEnabled` private * chore: versions * fix: add types for loader artifact * chore: eslintignore esm loader * chore: lint after merge * chore: update versions * chore: link to the test and upstream issue * refactor: pass conditions directly to `resolve.exports` * ci: set config as env variables * chore: update warning message * refactor: use `changeFilePromise` to update the loader * ci: remove Astro e2e test I've added integration tests that cover the same things * test: add link to issue Co-authored-by: Maël Nison <nison.mael@gmail.com>
- Loading branch information
Showing
28 changed files
with
995 additions
and
85 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
on: | ||
schedule: | ||
- cron: '0 */4 * * *' | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
paths: | ||
- .github/workflows/e2e-svelte-kit-workflow.yml | ||
- scripts/e2e-setup-ci.sh | ||
|
||
name: 'E2E SvelteKit' | ||
jobs: | ||
chore: | ||
name: 'Validating SvelteKit' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- name: 'Install Node' | ||
uses: actions/setup-node@master | ||
with: | ||
node-version: 14.x | ||
|
||
- name: 'Build the standard bundle' | ||
run: | | ||
node ./scripts/run-yarn.js build:cli | ||
- name: 'Running the integration test' | ||
run: | | ||
source scripts/e2e-setup-ci.sh | ||
yes | yarn create svelte@next my-app && cd my-app | ||
yarn | ||
yarn build | ||
Binary file not shown.
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
releases: | ||
"@yarnpkg/cli": minor | ||
"@yarnpkg/plugin-pnp": minor | ||
"@yarnpkg/pnp": minor | ||
|
||
declined: | ||
- "@yarnpkg/esbuild-plugin-pnp" | ||
- "@yarnpkg/plugin-compat" | ||
- "@yarnpkg/plugin-constraints" | ||
- "@yarnpkg/plugin-dlx" | ||
- "@yarnpkg/plugin-essentials" | ||
- "@yarnpkg/plugin-init" | ||
- "@yarnpkg/plugin-interactive-tools" | ||
- "@yarnpkg/plugin-nm" | ||
- "@yarnpkg/plugin-npm-cli" | ||
- "@yarnpkg/plugin-pack" | ||
- "@yarnpkg/plugin-patch" | ||
- "@yarnpkg/plugin-pnpm" | ||
- "@yarnpkg/plugin-stage" | ||
- "@yarnpkg/plugin-typescript" | ||
- "@yarnpkg/plugin-version" | ||
- "@yarnpkg/plugin-workspace-tools" | ||
- "@yarnpkg/builder" | ||
- "@yarnpkg/core" | ||
- "@yarnpkg/doctor" | ||
- "@yarnpkg/nm" | ||
- "@yarnpkg/pnpify" | ||
- "@yarnpkg/sdks" |
This file contains 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
This file contains 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
1 change: 1 addition & 0 deletions
1
packages/acceptance-tests/pkg-tests-fixtures/packages/no-deps-bins-esm-1.0.0/index.mjs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log(42); |
6 changes: 6 additions & 0 deletions
6
packages/acceptance-tests/pkg-tests-fixtures/packages/no-deps-bins-esm-1.0.0/package.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "no-deps-bins-esm", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"bin": "./index.mjs" | ||
} |
1 change: 1 addition & 0 deletions
1
packages/acceptance-tests/pkg-tests-fixtures/packages/no-deps-exports-1.0.0/index.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports.foo = 42; |
4 changes: 4 additions & 0 deletions
4
packages/acceptance-tests/pkg-tests-fixtures/packages/no-deps-exports-1.0.0/package.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "no-deps-exports", | ||
"version": "1.0.0" | ||
} |
Oops, something went wrong.