Corey Farrell
4ec02d5afd
module: fix dynamic import from eval
...
This allows dynamic import to work from CLI `--eval` with or without
`--input-type=module`.
Fixes: https://github.com/nodejs/node/issues/30591
PR-URL: https://github.com/nodejs/node/pull/30624
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com >
Reviewed-By: Ben Coe <bencoe@gmail.com >
2019-12-06 17:55:02 -08:00
Michaël Zasso
0646eda4fc
lib: flatten access to primordials
...
Store all primordials as properties of the primordials object.
Static functions are prefixed by the constructor's name and prototype
methods are prefixed by the constructor's name followed by "Prototype".
For example: primordials.Object.keys becomes primordials.ObjectKeys.
PR-URL: https://github.com/nodejs/node/pull/30610
Refs: https://github.com/nodejs/node/issues/29766
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2019-11-25 10:28:15 +01:00
Bradley Farias
a6b030d5ac
module: refactor modules bootstrap
...
PR-URL: https://github.com/nodejs/node/pull/29937
Reviewed-By: Myles Borins <myles.borins@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2019-10-16 21:50:05 -04:00
Gus Caplan
f9caee986c
vm: add Synthetic modules
...
- Refactor vm.SourceTextModule (again)
- Add vm.Module abstract superclass
- Add vm.SyntheticModule
Refs: https://heycam.github.io/webidl/#synthetic-module-records
PR-URL: https://github.com/nodejs/node/pull/29864
Reviewed-By: Guy Bedford <guybedford@gmail.com >
2019-10-14 14:25:38 -07:00
Guy Bedford
ffd22e8198
module: use v8 synthetic modules
...
PR-URL: https://github.com/nodejs/node/pull/29846
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Minwoo Jung <minwoo@nodesource.com >
2019-10-06 13:30:11 -04:00
Gus Caplan and Michaël Zasso
5e7946fe79
vm: refactor SourceTextModule
...
- Removes redundant `instantiate` method
- Refactors `link` to match the spec linking steps more accurately
- Removes URL validation from SourceTextModule specifiers
- DRYs some dynamic import logic
Closes: https://github.com/nodejs/node/issues/29030
Co-Authored-By: Michaël Zasso <targos@protonmail.com >
PR-URL: https://github.com/nodejs/node/pull/29776
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Minwoo Jung <minwoo@nodesource.com >
2019-10-02 15:54:35 -07:00
Bradley Farias and Jan Olaf Krems
9fd9efa492
esm: support loading data URLs
...
Co-Authored-By: Jan Olaf Krems <jan.krems@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/28614
Reviewed-By: Jan Krems <jan.krems@gmail.com >
2019-08-20 09:34:18 -05:00
Guy Bedford
4565292a77
esm: ensure cwd-relative imports for module --eval
...
PR-URL: https://github.com/nodejs/node/pull/28389
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2019-06-30 13:21:09 -04:00
Myles Borins
bbc254db5d
esm: --experimental-wasm-modules integration support
...
PR-URL: https://github.com/nodejs/node/pull/27659
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Myles Borins <myles.borins@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2019-05-17 02:25:20 +02:00
Michaël Zasso
112cc7c275
lib: use safe methods from primordials
...
This changes the primordials to expose built-in prototypes with their
methods already uncurried.
The uncurryThis function is therefore moved to the primordials.
All uses of uncurryThis on built-ins are changed to import the relevant
prototypes from primordials.
All uses of Function.call.bind are also changed to use primordials.
PR-URL: https://github.com/nodejs/node/pull/27096
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2019-04-08 11:23:09 +02:00
Myles Borins
7a547098d5
esm: use primordials
...
Converted uses of Object and Map to use frozen built
in primordials.
PR-URL: https://github.com/nodejs/node/pull/26954
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
2019-03-30 13:02:33 +01:00
b1094dbe19
esm: phase two of new esm implementation
...
This PR updates the current `--experimental-modules` implementation
based on the work of the modules team and reflects Phase 2 of our
new modules plan.
The largest differences from the current implementation include
* `packge.type` which can be either `module` or `commonjs`
- `type: "commonjs"`:
- `.js` is parsed as commonjs
- default for entry point without an extension is commonjs
- `type: "module"`:
- `.js` is parsed as esm
- does not support loading JSON or Native Module by default
- default for entry point without an extension is esm
* `--entry-type=[mode]`
- allows you set the type on entry point.
* A new file extension `.cjs`.
- this is specifically to support importing commonjs in the
`module` mode.
- this is only in the esm loader, the commonjs loader remains
untouched, but the extension will work in the old loader if you use
the full file path.
* `--es-module-specifier-resolution=[type]`
- options are `explicit` (default) and `node`
- by default our loader will not allow for optional extensions in
the import, the path for a module must include the extension if
there is one
- by default our loader will not allow for importing directories that
have an index file
- developers can use `--es-module-specifier-resolution=node` to
enable the commonjs specifier resolution algorithm
- This is not a “feature” but rather an implementation for
experimentation. It is expected to change before the flag is
removed
* `--experimental-json-loader`
- the only way to import json when `"type": "module"`
- when enable all `import 'thing.json'` will go through the
experimental loader independent of mode
- based on https://github.com/whatwg/html/issues/4315
* You can use `package.main` to set an entry point for a module
- the file extensions used in main will be resolved based on the
`type` of the module
Refs: https://github.com/nodejs/modules/blob/master/doc/plan-for-new-modules-implementation.md
Refs: https://github.com/GeoffreyBooth/node-import-file-specifier-resolution-proposal
Refs: https://github.com/nodejs/modules/pull/180
Refs: https://github.com/nodejs/ecmascript-modules/pull/6
Refs: https://github.com/nodejs/ecmascript-modules/pull/12
Refs: https://github.com/nodejs/ecmascript-modules/pull/28
Refs: https://github.com/nodejs/modules/issues/255
Refs: https://github.com/whatwg/html/issues/4315
Refs: https://github.com/w3c/webcomponents/issues/770
Co-authored-by: Myles Borins <MylesBorins@google.com >
Co-authored-by: John-David Dalton <john.david.dalton@gmail.com >
Co-authored-by: Evan Plaice <evanplaice@gmail.com >
Co-authored-by: Geoffrey Booth <webmaster@geoffreybooth.com >
Co-authored-by: Michaël Zasso <targos@protonmail.com >
PR-URL: https://github.com/nodejs/node/pull/26745
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Ben Coe <bencoe@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com >
2019-03-27 15:52:11 -04:00
dnlup
ad661ca209
module: remove usage of require('util') in esm/loader.js
...
Use `require('internal/util/debuglog').debuglog` instead of
`require('util').debuglog` in `lib/internal/modules/esm/loader.js`.
PR-URL: https://github.com/nodejs/node/pull/26804
Refs: https://github.com/nodejs/node/issues/26546
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-03-25 00:33:06 +01:00
Ruben Bridgewater
50dd555910
doc,lib,test: capitalize comment sentences
...
This activates the eslint capitalize comment rule for comments
above 50 characters.
PR-URL: https://github.com/nodejs/node/pull/24996
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2018-12-17 17:14:35 +01:00
ZYSzys
d695a019ae
module: use validateString in modules/esm
...
PR-URL: https://github.com/nodejs/node/pull/24868
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2018-12-10 09:48:49 -08:00
cjihrig
a64ca7139e
esm: remove unused catch bindings
...
PR-URL: https://github.com/nodejs/node/pull/24079
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: Wyatt Preul <wpreul@gmail.com >
2018-11-06 10:58:56 -05:00
Сковорода Никита Андреевич
7bdc694267
errors: fix ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK
...
This restores a broken and erroneously removed error, which was
accidentially renamed to ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK (notice
the "INTST" vs "INST") in 921fb84687
(PR #16874 ) and then had documentation and implementation removed under
the old name in 6e1c25c456 (PR #18857 ),
as it appeared unused.
This error code never worked or was documented under the mistyped name
ERR_MISSING_DYNAMIC_INTSTANTIATE_HOOK, so renaming it back to
ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK is a semver-patch fix.
Refs: https://github.com/nodejs/node/issues/21440
Refs: https://github.com/nodejs/node/pull/21470
Refs: https://github.com/nodejs/node/pull/16874
Refs: https://github.com/nodejs/node/pull/18857
PR-URL: https://github.com/nodejs/node/pull/21493
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Ron Korving <ron@ronkorving.nl >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2018-06-30 23:48:59 +02:00
guybedford
1bf42f4777
esm: loader hook URL validation and error messages
...
PR-URL: https://github.com/nodejs/node/pull/21352
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
2018-06-30 02:07:51 +02:00
Guy Bedford
8ee604ca71
esm: ensure require.main for CJS top-level loads
...
PR-URL: https://github.com/nodejs/node/pull/21150
Reviewed-By: Bradley Farias <bradley.meck@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
2018-06-13 17:58:11 +02:00
Daniel Bevenius
f2b10799ef
lib: rename js source to lower snake_case
...
This commit renames all JavaScript source files in lib to lower
snake_case.
PR-URL: https://github.com/nodejs/node/pull/19556
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com >
2018-03-28 08:09:16 +02:00