Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix node.js externals #6530

Merged
merged 6 commits into from
Nov 21, 2023
Merged

fix node.js externals #6530

merged 6 commits into from
Nov 21, 2023

Conversation

sokra
Copy link
Member

@sokra sokra commented Nov 21, 2023

Description

  • Extend resolving to allow reference type for plugins
  • add extensions for MainField
  • add an option import_externals to context to specify externals behavior for ESM imports
    • false: require() is used
    • true: import() is used and the module becomes an async module
  • adds import_externals: false support for dynamic import
  • adds import_externals: true support for normal import

see also vercel/next.js#58129

Testing Instructions

Closes PACK-2011

Copy link

vercel bot commented Nov 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-basic-web 🔄 Building (Inspect) Visit Preview 💬 Add feedback Nov 21, 2023 5:27pm
examples-kitchensink-blog 🔄 Building (Inspect) Visit Preview 💬 Add feedback Nov 21, 2023 5:27pm
examples-svelte-web 🔄 Building (Inspect) Visit Preview 💬 Add feedback Nov 21, 2023 5:27pm
8 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-cra-web ⬜️ Ignored (Inspect) Visit Preview Nov 21, 2023 5:27pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Nov 21, 2023 5:27pm
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Nov 21, 2023 5:27pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Nov 21, 2023 5:27pm
examples-nonmonorepo ⬜️ Ignored (Inspect) Visit Preview Nov 21, 2023 5:27pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Nov 21, 2023 5:27pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Nov 21, 2023 5:27pm
turbo-site ⬜️ Ignored (Inspect) Visit Preview Nov 21, 2023 5:27pm

Copy link
Contributor

github-actions bot commented Nov 21, 2023

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Copy link
Contributor

✅ This change can build next-swc

Copy link
Contributor

github-actions bot commented Nov 21, 2023

⚠️ CI failed ⚠️

The following steps have failed in CI:

  • Turbopack Rust tests (mac/win, non-blocking)

See workflow summary for details

Copy link
Contributor

Linux Benchmark for 0b8b6ed

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 23.22ms ± 1.00ms 23.84ms ± 0.71ms +2.63%
bench_hmr_to_eval/Turbopack CSR/1000 modules 22.86ms ± 0.87ms 22.66ms ± 1.02ms -0.86%
bench_startup/Turbopack CSR/1000 modules 1112.22ms ± 5.09ms 1108.98ms ± 18.57ms -0.29%

Copy link
Contributor

Linux Benchmark for 163154a

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 21.45ms ± 0.78ms 21.34ms ± 0.83ms -0.50%
bench_hmr_to_eval/Turbopack CSR/1000 modules 21.02ms ± 0.77ms 21.33ms ± 0.83ms +1.47%
bench_startup/Turbopack CSR/1000 modules 1088.57ms ± 5.29ms 1092.55ms ± 9.93ms +0.37%

@sokra sokra changed the title Sokra/fix node externals fix node.js externals Nov 21, 2023
Copy link
Contributor

Linux Benchmark for acde138

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 23.56ms ± 0.87ms 23.33ms ± 0.97ms -0.99%
bench_hmr_to_eval/Turbopack CSR/1000 modules 23.39ms ± 1.16ms 22.93ms ± 0.95ms -1.95%
bench_startup/Turbopack CSR/1000 modules 1099.64ms ± 4.89ms 1095.85ms ± 9.51ms -0.34%

Copy link
Contributor

Linux Benchmark for ac3de8a

Test Base PR % Significant %
bench_startup/Turbopack CSR/1000 modules 1142.74ms ± 14.00ms 1096.12ms ± 6.46ms -4.08% -0.51%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 23.48ms ± 0.94ms 23.45ms ± 0.98ms -0.14%
bench_hmr_to_eval/Turbopack CSR/1000 modules 22.96ms ± 0.98ms 22.92ms ± 0.94ms -0.16%
bench_startup/Turbopack CSR/1000 modules 1142.74ms ± 14.00ms 1096.12ms ± 6.46ms -4.08% -0.51%

@@ -1,10 +1,11 @@
//! TODO(WEB-741) Remove this file once Sass is supported.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just nit but I guess this can be actually removed? prolly not for this pr.

@sokra sokra merged commit 46a3854 into main Nov 21, 2023
53 of 55 checks passed
@sokra sokra deleted the sokra/fix-node-externals branch November 21, 2023 20:32
wbinnssmith pushed a commit to vercel/next.js that referenced this pull request Nov 21, 2023
### What?

Various fixes in handling of externals in node.js

* add extensions to builtin externals to allow node.js ESM to work
* improve the auto-externals logic to detect more edge cases
* prepare for `esmExternals` support, but that's blocked by client
manifest missing the async flag
* currently only `esmExternals: false` is supported

### Why?

### Turbopack Changes

* vercel/turborepo#6531 <!-- Leah - fix(turbopack):
postcss should be applied to `@import`ed CSS files -->
* vercel/turborepo#6530 <!-- Tobias Koppers - fix
node.js externals -->

---------

Co-authored-by: Leah <github.leah@hrmny.sh>
Co-authored-by: Zack Tanner <zacktanner@gmail.com>
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 25, 2024
### Description

* Extend resolving to allow reference type for plugins
* add extensions for MainField
* add an option `import_externals` to context to specify externals
behavior for ESM imports
  * false: require() is used
  * true: import() is used and the module becomes an async module
* adds `import_externals: false` support for dynamic import
* adds `import_externals: true` support for normal import

see also #58129

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->


Closes PACK-2011
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
### Description

* Extend resolving to allow reference type for plugins
* add extensions for MainField
* add an option `import_externals` to context to specify externals
behavior for ESM imports
  * false: require() is used
  * true: import() is used and the module becomes an async module
* adds `import_externals: false` support for dynamic import
* adds `import_externals: true` support for normal import

see also #58129

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->


Closes PACK-2011
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
### Description

* Extend resolving to allow reference type for plugins
* add extensions for MainField
* add an option `import_externals` to context to specify externals
behavior for ESM imports
  * false: require() is used
  * true: import() is used and the module becomes an async module
* adds `import_externals: false` support for dynamic import
* adds `import_externals: true` support for normal import

see also #58129

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->


Closes PACK-2011
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 1, 2024
### Description

* Extend resolving to allow reference type for plugins
* add extensions for MainField
* add an option `import_externals` to context to specify externals
behavior for ESM imports
  * false: require() is used
  * true: import() is used and the module becomes an async module
* adds `import_externals: false` support for dynamic import
* adds `import_externals: true` support for normal import

see also #58129

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->


Closes PACK-2011
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.

2 participants