Guy Bedford
832640c35e
esm: support top-level Wasm without package type
...
PR-URL: https://github.com/nodejs/node/pull/57610
Reviewed-By: Jordan Harband <ljharb@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-05-19 12:13:50 +02:00
Marco Ippolito
3082ab3a64
test: module syntax should throw
...
PR-URL: https://github.com/nodejs/node/pull/57121
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com >
2025-04-17 10:51:37 -03:00
Dario Piotrowicz
854370a06c
src: fix process exit listeners not receiving unsettled tla codes
...
fix listeners registered via `process.on('exit', ...` not receiving
error code 13 when an unsettled top-level-await is encountered in
the code
PR-URL: https://github.com/nodejs/node/pull/56872
Fixes: https://github.com/nodejs/node/issues/53551
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2025-04-17 10:51:29 -03:00
Antoine du Hamel
17e21e6eb5
test: use assert.match in test-esm-import-meta
...
PR-URL: https://github.com/nodejs/node/pull/57290
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2025-04-17 10:51:26 -03:00
Mert Can Altin
4c29cc7e6b
module: add dynamic file-specific ESM warnings
...
PR-URL: https://github.com/nodejs/node/pull/56628
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-04-17 10:51:17 -03:00
Joyee Cheung
d1845edd21
module: improve error message from asynchronicity in require(esm)
...
- Improve the error message that shows up when there is a race
from doing require(esm) and import(esm) at the same time.
- Improve error message of ERR_REQUIRE_ASYNC_MODULE by showing
parent and target file names, if available.
Drive-by: split the require(tla) tests since we are modifying
the tests already.
PR-URL: https://github.com/nodejs/node/pull/57126
Refs: https://github.com/fisker/prettier-issue-17139
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2025-04-17 10:51:02 -03:00
Carlos Espa
afae4b1216
test: change jenkins reporter
...
PR-URL: https://github.com/nodejs/node/pull/56808
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2025-04-16 03:26:28 -03:00
Marco Ippolito
1614e8e7bc
module: add ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX
...
PR-URL: https://github.com/nodejs/node/pull/56610
Backport-PR-URL: https://github.com/nodejs/node/pull/56912
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2025-02-06 01:15:07 +01:00
Marco Ippolito
174d88eab1
module: support eval with ts syntax detection
...
PR-URL: https://github.com/nodejs/node/pull/56285
Backport-PR-URL: https://github.com/nodejs/node/pull/56912
Refs: https://github.com/nodejs/typescript/issues/17
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
2025-02-06 01:14:37 +01:00
James M Snell
1795202d19
test: rely less on duplicative common test harness utilities
...
There are several cleanups here that are not just style nits...
1. The `common.isMainThread` was just a passthrough to the
`isMainThread` export on the worker_thread module. It's
use was inconsistent and just obfuscated the fact that
the test file depend on the `worker_threads` built-in.
By eliminating it we simplify the test harness a bit and
make it clearer which tests depend on the worker_threads
check.
2. The `common.isDumbTerminal` is fairly unnecesary since
that just wraps a public API check.
3. Several of the `common.skipIf....` checks were inconsistently
used and really don't need to be separate utility functions.
A key part of the motivation here is to work towards making more
of the tests more self-contained and less reliant on the common
test harness where possible.
PR-URL: https://github.com/nodejs/node/pull/56712
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2025-02-06 01:10:39 +01:00
Antoine du Hamel
0362924880
test: use unusual chars in the path to ensure our tests are robust
...
PR-URL: https://github.com/nodejs/node/pull/48409
Reviewed-By: Jacob Smith <jacob@frende.me >
2025-01-31 01:16:46 +01:00
Marco Ippolito
cc648ef923
test: enable ts test on win arm64
...
PR-URL: https://github.com/nodejs/node/pull/56349
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com >
2025-01-31 01:16:45 +01:00
Marco Ippolito
4352bf69e9
test: check typescript loader
...
PR-URL: https://github.com/nodejs/node/pull/54657
Refs: https://github.com/nodejs/node/issues/54645
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2025-01-31 01:16:44 +01:00
RafaelGSS
2446870618
src,loader,permission: throw on InternalWorker use
...
Previously this PR it was expected that InternalWorker
usage doesn't require the --allow-worker when the permission
model is enabled. This, however, exposes a vulnerability
whenever the instance gets accessed by the user. For example
through diagnostics_channel.subscribe('worker_threads')
PR-URL: https://github.com/nodejs-private/node-private/pull/651
Refs: https://github.com/nodejs-private/node-private/pull/629
CVE-ID: CVE-2025-23083
2025-01-20 10:47:28 -03:00
Rafael Gonzaga
57bb983215
src,lib: stabilize permission model
...
Move permission model from 1.1 (Active Development)
to 2.0 (Stable).
PR-URL: https://github.com/nodejs/node/pull/56201
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
2025-01-05 13:05:28 -05:00
Joyee Cheung
7cbe3de1d8
module: only emit require(esm) warning under --trace-require-module
...
require(esm) is relatively stable now and the experimental warning
has run its course - it's now more troublesome than useful.
This patch changes it to no longer emit a warning unless
`--trace-require-module` is explicitly used. The flag supports
two modes:
- `--trace-require-module=all`: emit warnings for all usages
- `--trace-require-module=no-node-modules`: emit warnings for
usages that do not come from a `node_modules` folder.
PR-URL: https://github.com/nodejs/node/pull/56194
Fixes: https://github.com/nodejs/node/issues/55417
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
2025-01-05 13:05:26 -05:00
Shima Ryuhei
8a5429c9b3
module: prevent main thread exiting before esm worker ends
...
PR-URL: https://github.com/nodejs/node/pull/56183
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
2025-01-05 13:05:26 -05:00
Joyee Cheung
28a11adf14
module: mark evaluation rejection in require(esm) as handled
...
Previously the implemention of require(esm) only converted the
rejected promise from module evaluation into an error, but the
rejected promise was still treated as a pending unhandled
rejection by the promise rejection callback, because the promise
is created by V8 internals and we don't get a chance to mark
it as handled, so the rejection incorrectly marked as unhandled
would still go through unhandled rejection handling (if no
global listener is set, the default handling would print a warning
and make the Node.js instance exit with 1).
This patch fixes it by calling into the JS promise rejection
callback to mark the evalaution rejection handled so that
it doesn't go through unhandled rejection handling.
PR-URL: https://github.com/nodejs/node/pull/56122
Fixes: https://github.com/nodejs/node/issues/56115
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
2025-01-05 12:57:35 -05:00
Marco Ippolito
ae2ae2fef1
esm: fix import.meta.resolve crash
...
PR-URL: https://github.com/nodejs/node/pull/55777
Fixes: https://github.com/nodejs/node/issues/55518
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2024-11-27 11:03:35 -05:00
Antoine du Hamel
fc69080669
test: refactor some esm tests
...
PR-URL: https://github.com/nodejs/node/pull/55472
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
2024-11-27 11:03:31 -05:00
dependabot[bot]
0a79ebd257
tools: update ESLint to 9.14.0
...
Bumps the eslint group with 7 updates in the /tools/eslint directory:
| Package | From | To |
| --- | --- | --- |
| [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core ) | `7.25.2` | `7.26.0` |
| [@babel/eslint-parser](https://github.com/babel/babel/tree/HEAD/eslint/babel-eslint-parser ) | `7.25.1` | `7.25.9` |
| [@babel/plugin-syntax-import-attributes](https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-syntax-import-attributes ) | `7.25.6` | `7.26.0` |
| [@stylistic/eslint-plugin-js](https://github.com/eslint-stylistic/eslint-stylistic/tree/HEAD/packages/eslint-plugin-js ) | `2.8.0` | `2.10.1` |
| [eslint](https://github.com/eslint/eslint ) | `9.11.1` | `9.14.0` |
| [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc ) | `50.3.1` | `50.4.3` |
| [globals](https://github.com/sindresorhus/globals ) | `15.10.0` | `15.11.0` |
Updates `@babel/core` from 7.25.2 to 7.26.0
- [Release notes](https://github.com/babel/babel/releases )
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md )
- [Commits](https://github.com/babel/babel/commits/v7.26.0/packages/babel-core )
Updates `@babel/eslint-parser` from 7.25.1 to 7.25.9
- [Release notes](https://github.com/babel/babel/releases )
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md )
- [Commits](https://github.com/babel/babel/commits/v7.25.9/eslint/babel-eslint-parser )
Updates `@babel/plugin-syntax-import-attributes` from 7.25.6 to 7.26.0
- [Release notes](https://github.com/babel/babel/releases )
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md )
- [Commits](https://github.com/babel/babel/commits/v7.26.0/packages/babel-plugin-syntax-import-attributes )
Updates `@stylistic/eslint-plugin-js` from 2.8.0 to 2.10.1
- [Release notes](https://github.com/eslint-stylistic/eslint-stylistic/releases )
- [Changelog](https://github.com/eslint-stylistic/eslint-stylistic/blob/main/CHANGELOG.md )
- [Commits](https://github.com/eslint-stylistic/eslint-stylistic/commits/v2.10.1/packages/eslint-plugin-js )
Updates `eslint` from 9.11.1 to 9.14.0
- [Release notes](https://github.com/eslint/eslint/releases )
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md )
- [Commits](https://github.com/eslint/eslint/compare/v9.11.1...v9.14.0 )
Updates `eslint-plugin-jsdoc` from 50.3.1 to 50.4.3
- [Release notes](https://github.com/gajus/eslint-plugin-jsdoc/releases )
- [Changelog](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/.releaserc )
- [Commits](https://github.com/gajus/eslint-plugin-jsdoc/compare/v50.3.1...v50.4.3 )
Updates `globals` from 15.10.0 to 15.11.0
- [Release notes](https://github.com/sindresorhus/globals/releases )
- [Commits](https://github.com/sindresorhus/globals/compare/v15.10.0...v15.11.0 )
---
updated-dependencies:
- dependency-name: "@babel/core"
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: eslint
- dependency-name: "@babel/eslint-parser"
dependency-type: direct:production
update-type: version-update:semver-patch
dependency-group: eslint
- dependency-name: "@babel/plugin-syntax-import-attributes"
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: eslint
- dependency-name: "@stylistic/eslint-plugin-js"
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: eslint
- dependency-name: eslint
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: eslint
- dependency-name: eslint-plugin-jsdoc
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: eslint
- dependency-name: globals
dependency-type: direct:production
update-type: version-update:semver-minor
dependency-group: eslint
...
Signed-off-by: dependabot[bot] <support@github.com >
PR-URL: https://github.com/nodejs/node/pull/55689
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2024-11-27 11:03:31 -05:00
Joyee Cheung
91fdec3a52
module: fix error thrown from require(esm) hitting TLA repeatedly
...
This tracks the asynchronicity in the ModuleWraps when they turn out to
contain TLA after instantiation, and throw the right error
(ERR_REQUIRE_ASYNC_MODULE) when it's required again. It removes
the freezing of ModuleWraps since it's not meaningful to freeze
this when the rest of the module loader is mutable, and we
can record the asynchronicity in the ModuleWrap right after
compilation after we get a V8 upgrade that contains
v8::Module::HasTopLevelAwait() instead of searching through
the module graph repeatedly which can be slow.
PR-URL: https://github.com/nodejs/node/pull/55520
Fixes: https://github.com/nodejs/node/issues/55516
Refs: https://github.com/nodejs/node/issues/52697
Reviewed-By: Paolo Insogna <paolo@cowtech.it >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
2024-11-27 11:03:26 -05:00
Antoine du Hamel
15dd43dd6e
esm: add a fallback when importer in not a file
...
PR-URL: https://github.com/nodejs/node/pull/55471
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com >
2024-11-27 02:25:38 -05:00
Wei Zhu
aed758d270
esm: fix inconsistency with importAssertion in resolve hook
...
As the documentation states, the `context.importAssertion` should be
still supported and emit a warning. This is true for the `load` hook,
but not correct for context of the `resolve` hook.
This commit fixes the inconsistency.
PR-URL: https://github.com/nodejs/node/pull/55365
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2024-11-27 01:37:51 -05:00
Joyee Cheung
cb527a925d
module: do not warn when require(esm) comes from node_modules
...
As part of the standard experimental feature graduation
policy, when we unflagged require(esm) we moved the
experimental warning to be emitted when require() is
actually used to load ESM, which previously was an error.
However, some packages in the ecosystem have already
being using try-catch to load require(esm) to e.g.
resolve optional dependency, and emitting warning from
there instead of throwing directly could break the CLI
output.
To reduce the disruption for releases, as a compromise, this
patch skips the warning if require(esm) comes from
node_modules, where users typically don't have much control
over the code. This warning will be eventually removed
when require(esm) becomes stable.
This patch was originally intended for the LTS releases,
though it seems there's appetite for it on v23.x as
well so it's re-targeted to the main branch.
PR-URL: https://github.com/nodejs/node/pull/55960
Backport-PR-URL: https://github.com/nodejs/node/pull/55217
Refs: https://github.com/nodejs/node/pull/55217
Refs: https://github.com/nodejs/node/issues/52697
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
2024-11-27 00:45:39 -05:00
Joyee Cheung
16119f206f
module: trim off internal stack frames for require(esm) warnings
...
Trim off irrelevant internal stack frames for require(esm) warnings
so it's easier to locate where the call comes from when
--trace-warnings is used.
PR-URL: https://github.com/nodejs/node/pull/55496
Backport-PR-URL: https://github.com/nodejs/node/pull/55217
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Paolo Insogna <paolo@cowtech.it >
Refs: https://github.com/nodejs/node/issues/52697
2024-11-27 00:45:34 -05:00
Joyee Cheung
28b5b9a57d
module: allow ESM that failed to be required to be re-imported
...
When a ESM module cannot be loaded by require due to the presence
of TLA, its module status would be stopped at kInstantiated. In
this case, when it's imported again, we should allow it to be
evaluated asynchronously, as it's also a common pattern for users
to retry with dynamic import when require fails.
PR-URL: https://github.com/nodejs/node/pull/55502
Backport-PR-URL: https://github.com/nodejs/node/pull/55217
Fixes: https://github.com/nodejs/node/issues/55500
Refs: https://github.com/nodejs/node/issues/52697
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
2024-11-27 00:45:27 -05:00
Joyee Cheung
6ac3400960
module: include module information in require(esm) warning
...
When emitting the experimental warning for `require(esm)`, include
information about the parent module and the module being require()-d
to help users locate and update them.
PR-URL: https://github.com/nodejs/node/pull/55397
Backport-PR-URL: https://github.com/nodejs/node/pull/55217
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Refs: https://github.com/nodejs/node/issues/52697
2024-11-27 00:45:18 -05:00
Joyee Cheung
fcdd6167d8
module: check --experimental-require-module separately from detection
...
Previously we assumed if `--experimental-detect-module` is true, then
`--experimental-require-module` is true, which isn't the case, as
the two can be enabled/disabled separately. This patch fixes the
checks so `--no-experimental-require-module` is still effective when
`--experimental-detect-module` is enabled.
Drive-by: make the assertion messages more informative and remove
obsolete TODO about allowing TLA in entrypoints handled by
require(esm).
PR-URL: https://github.com/nodejs/node/pull/55250
Backport-PR-URL: https://github.com/nodejs/node/pull/55217
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Refs: https://github.com/nodejs/node/issues/52697
2024-11-27 00:45:12 -05:00
Guy Bedford
545c069eb5
module: support 'module.exports' interop export in require(esm)
...
PR-URL: https://github.com/nodejs/node/pull/54563
Backport-PR-URL: https://github.com/nodejs/node/pull/55217
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Refs: https://github.com/nodejs/node/issues/52697
2024-11-27 00:44:51 -05:00
Joyee Cheung
58d6871c45
module: unflag --experimental-require-module
...
This unflags --experimental-require-module so require(esm) can be
used without the flag. For now, when require() actually encounters
an ESM, it will still emit an experimental warning. To opt out
of the feature, --no-experimental-require-module can be used.
There are some tests specifically testing ERR_REQUIRE_ESM. Some
of them are repurposed to test --no-experimental-require-module.
Some of them are modified to just expect loading require(esm) to
work, when it's appropriate.
PR-URL: https://github.com/nodejs/node/pull/55085
Backport-PR-URL: https://github.com/nodejs/node/pull/55217
Refs: https://github.com/nodejs/node/issues/52697
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: LiviaMedeiros <livia@cirno.name >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Michael Dawson <midawson@redhat.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
2024-11-27 00:44:46 -05:00
Nicolò Ribaudo
88d91e8bc2
esm: mark import attributes and JSON module as stable
...
The two proposals reached stage 4 at the October 2024 meeting.
PR-URL: https://github.com/nodejs/node/pull/55333
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2024-11-16 17:45:08 +01:00
Joyee Cheung
e95163b170
process: add process.features.require_module
...
For detecting whether `require(esm)` is supported without triggering
the experimental warning.
PR-URL: https://github.com/nodejs/node/pull/55241
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2024-10-11 23:58:11 +02:00
Antoine du Hamel
0655d3a384
process: fix process.features.typescript when Amaro is unavailable
...
PR-URL: https://github.com/nodejs/node/pull/55323
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
2024-10-11 20:58:16 +02:00
Richard Lau
3273707a3a
test: fix tests when Amaro is unavailable
...
Fix two tests that fail when `node` is configured `--without-amaro`.
PR-URL: https://github.com/nodejs/node/pull/55320
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Chemi Atlow <chemi@atlow.co.il >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2024-10-11 09:04:16 +02:00
Marco Ippolito
6fcac73738
module: wrap swc error in ERR_INVALID_TYPESCRIPT_SYNTAX
...
PR-URL: https://github.com/nodejs/node/pull/55316
Reviewed-By: Paolo Insogna <paolo@cowtech.it >
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2024-10-11 09:04:07 +02:00
Antoine du Hamel
17d2f9de6d
test: make test-loaders-workers-spawned less flaky
...
PR-URL: https://github.com/nodejs/node/pull/55172
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2024-10-09 22:59:04 +02:00
Aviv Keller
4050f68e5d
process: add process.features.typescript
...
PR-URL: https://github.com/nodejs/node/pull/54295
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2024-10-05 12:36:22 +02:00
Kevin Toshihiro Uehara
ce67e7b5b3
test: adding more tests for strip-types
...
PR-URL: https://github.com/nodejs/node/pull/54929
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Michael Dawson <midawson@redhat.com >
2024-10-04 19:20:21 +02:00
Nathan Baulch
9aeba48bf0
test: fix typos
...
PR-URL: https://github.com/nodejs/node/pull/55063
Reviewed-By: Filip Skokan <panva.ip@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2024-10-04 19:20:16 +02:00
Antoine du Hamel
0fb446e207
esm: do not interpret "main" as a URL
...
As documented, its value is a path.
PR-URL: https://github.com/nodejs/node/pull/55003
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2024-10-04 19:20:13 +02:00
Christos Koutsiaris
0999b5e493
test: remove duplicated test descriptions
...
PR-URL: https://github.com/nodejs/node/pull/54140
Reviewed-By: Michael Dawson <midawson@redhat.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2024-10-04 19:20:12 +02:00
RedYetiDev and Antoine du Hamel
32261fc98a
module: support loading entrypoint as url
...
Co-Authored-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/54933
Refs: https://github.com/nodejs/node/pull/49975
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: LiviaMedeiros <livia@cirno.name >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2024-10-04 19:20:12 +02:00
Antoine du Hamel
fdae57f1e1
test: fix some tests when path contains %
...
Tests should pass even if the path where the repo is cloned contains
URL-significant chars.
PR-URL: https://github.com/nodejs/node/pull/55082
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
2024-10-04 10:20:27 +02:00
Joyee Cheung
111261e245
module: implement the "module-sync" exports condition
...
This patch implements a "module-sync" exports condition
for packages to supply a sycnrhonous ES module to the
Node.js module loader, no matter it's being required
or imported. This is similar to the "module" condition
that bundlers have been using to support `require(esm)`
in Node.js, and allows dual-package authors to opt into
ESM-first only newer versions of Node.js that supports
require(esm) while avoiding the dual-package hazard.
```json
{
"type": "module",
"exports": {
"node": {
// On new version of Node.js, both require() and import get
// the ESM version
"module-sync": "./index.js",
// On older version of Node.js, where "module" and
// require(esm) are not supported, use the transpiled CJS version
// to avoid dual-package hazard. Library authors can decide
// to drop support for older versions of Node.js when they think
// it's time.
"default": "./dist/index.cjs"
},
// On any other environment, use the ESM version.
"default": "./index.js"
}
}
```
We end up implementing a condition with a different name
instead of reusing "module", because existing code in the
ecosystem using the "module" condition sometimes also expect
the module resolution for these ESM files to work in CJS
style, which is supported by bundlers, but the native
Node.js loader has intentionally made ESM resolution
different from CJS resolution (e.g. forbidding `import
'./noext'` or `import './directory'`), so it would be
semver-major to implement a `"module"` condition
without implementing the forbidden ESM resolution rules.
For now, this just implments a new condition as semver-minor
so it can be backported to older LTS.
Refs: https://webpack.js.org/guides/package-exports/#target-environment-independent-packages
PR-URL: https://github.com/nodejs/node/pull/54648
Fixes: https://github.com/nodejs/node/issues/52173
Refs: https://github.com/joyeecheung/test-module-condition
Refs: https://github.com/nodejs/node/issues/52697
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Jan Krems <jan.krems@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
2024-10-04 10:20:25 +02:00
Aviv Keller
327a8f7b59
test: fix invalid wasm test
...
PR-URL: https://github.com/nodejs/node/pull/54935
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2024-10-04 10:20:11 +02:00
Marco Ippolito
93c6c90219
test_runner: support typescript module mocking
...
PR-URL: https://github.com/nodejs/node/pull/54878
Fixes: https://github.com/nodejs/node/issues/54428
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: Erick Wendel <erick.workspace@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
Reviewed-By: Paolo Insogna <paolo@cowtech.it >
2024-10-04 10:20:10 +02:00
Antoine du Hamel
1d169764db
module: report unfinished TLA in ambiguous modules
...
PR-URL: https://github.com/nodejs/node/pull/54980
Fixes: https://github.com/nodejs/node/issues/54931
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2024-10-04 10:20:09 +02:00
Joyee Cheung
108cef22e6
module: remove bogus assertion in CJS entrypoint handling with --import
...
The synchronous CJS translator can handle entrypoints now, this
can be hit when --import is used, so lift the bogus assertions and
added tests.
PR-URL: https://github.com/nodejs/node/pull/54592
Fixes: https://github.com/nodejs/node/issues/54577
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2024-10-04 10:20:04 +02:00
Marco Ippolito
67ecb10c78
module: fix discrepancy between .ts and .js
...
PR-URL: https://github.com/nodejs/node/pull/54461
Backport-PR-URL: https://github.com/nodejs/node/pull/54566
Fixes: https://github.com/nodejs/node/issues/54457
Reviewed-By: Paolo Insogna <paolo@cowtech.it >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com >
2024-09-18 09:24:49 +02:00