summaryrefslogtreecommitdiff
path: root/test/es-module
AgeCommit message (Collapse)Author
2019-12-05module: fixup lint and test regressionsGuy Bedford
PR-URL: https://github.com/nodejs/node/pull/30802 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: João Reis <reis@janeasystems.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-12-04lib,test: improves ERR_REQUIRE_ESM messageJuan José Arboleda
PR-URL: https://github.com/nodejs/node/pull/30694 Fixes: https://github.com/nodejs/node/issues/30599 Reviewed-By: Guy Bedford <guybedford@gmail.com>
2019-12-04module: add warnings for experimental flagsRongjian Zhang
PR-URL: https://github.com/nodejs/node/pull/30617 Fixes: https://github.com/nodejs/node/issues/30600 Reviewed-By: Guy Bedford <guybedford@gmail.com>
2019-12-04esm: make specifier flag clearly experimentalMyles Borins
`--es-module-specifier-resolution` is the only flagged portion of the ESM implementation that does not have the word experimental in the flag name. This commit changes the flag to: `--experimental-specifier-resolution` `--es-module-specifier-resolution` remains as an alias for backwards compatibility but it is no longer documented. PR-URL: https://github.com/nodejs/node/pull/30678 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
2019-11-30benchmark,doc,lib,test: prepare for padding lint ruleRich Trott
Upcoming lint rule will require a blank line between consecutive functions. Add it in the places where we don't have it already. PR-URL: https://github.com/nodejs/node/pull/30696 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-11-28module: fix specifier resolution algorithmRongjian Zhang
Fixes: https://github.com/nodejs/node/issues/30520 PR-URL: https://github.com/nodejs/node/pull/30574 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
2019-11-26esm: data URLs should ignore unknown parametersBradley Farias
PR-URL: https://github.com/nodejs/node/pull/30593 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
2019-11-16esm: disable non-js exts outside package scopesGuy Bedford
PR-URL: https://github.com/nodejs/node/pull/30501 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
2019-11-12esm: unflag --experimental-modulesGuy Bedford
PR-URL: https://github.com/nodejs/node/pull/29866 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
2019-11-08module: conditional exports with flagged conditionsGuy Bedford
PR-URL: https://github.com/nodejs/node/pull/29978 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
2019-11-08module: fix for empty object in InternalModuleReadJSONGuy Bedford
Fixes: https://github.com/nodejs/node/issues/30245 PR-URL: https://github.com/nodejs/node/pull/30256 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com>
2019-10-24module: resolve self-referencesJan Krems
Adds the ability to `import` or `require` a package from within its own source code. This allows tests and examples to be written using the package name, making them easier to reuse by consumers of the package. Assuming the `name` field in `package.json` is set to `my-pkg`, its test could use `require('my-pkg')` or `import 'my-pkg'` even if there's no `node_modules/my-pkg` while testing the package itself. An important difference between this and relative specifiers like `require('../')` is that self-references use the public interface of the package as defined in the `exports` field while relative specifiers don't. This behavior is guarded by a new experimental flag (`--experimental-resolve-self`). PR-URL: https://github.com/nodejs/node/pull/29327 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-10-16esm: modify resolution order for specifier flagMyles Borins
Currently `--es-module-specifier-resolution=node` has an alternative resolution order than the default in common.js, this causes inconsistencies. As discussed in @nodejs/modules we want to preserve resolution order between implementations. PR-URL: https://github.com/nodejs/node/pull/29974 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-10-16module: refactor modules bootstrapBradley Farias
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-11module: warn on require of .js inside type: moduleGuy Bedford
PR-URL: https://github.com/nodejs/node/pull/29909 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-10-08Revert "esm: remove experimental status from JSON modules"Guy Bedford
This reverts commit ec8776da6fa77628e12718bb38cee687303d4137. PR-URL: https://github.com/nodejs/node/pull/29754 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
2019-10-05esm: remove proxy for builtin exportsBradley Farias
PR-URL: https://github.com/nodejs/node/pull/29737 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2019-10-03src: fix ESM path resolution on WindowsThomas
Windows has some reserved file names such as "con", "prn", "nul", etc. Such files can be accessed only if the path is prefixed with "\\.\" PR-URL: https://github.com/nodejs/node/pull/29574 Reviewed-By: Guy Bedford <guybedford@gmail.com>
2019-09-30src: rename --loader to --experimental-loaderAlex Aubuchon
Renames the `--loader` cli argument to `--experimental-loader`. This is to clearly indicate the esm loader feature as experimental even after esm is no longer experimental. Also minorly alters the `--experimental-loader` docs to say that the passed loader can be an esm module. Refs: https://github.com/nodejs/modules/issues/351#issuecomment-535189524 PR-URL: https://github.com/nodejs/node/pull/29752 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-09-28module: move cjs type check behind flagGuy Bedford
PR-URL: https://github.com/nodejs/node/pull/29732 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
2019-09-19module: error for CJS .js load within type: moduleGuy Bedford
PR-URL: https://github.com/nodejs/node/pull/29492 Reviewed-By: Jan Krems <jan.krems@gmail.com>
2019-09-17module: reintroduce package exports dot mainGuy Bedford
This reintroduces the dot main in exports as discussed in the previous Node.js modules meeting. The implementation includes both CommonJS and ES module resolution with the associated documentation and resolver specification changes. In addition to the dot main, "exports" as a string or direct fallback array is supported as well. Co-Authored-By: Geoffrey Booth <GeoffreyBooth@users.noreply.github.com> PR-URL: https://github.com/nodejs/node/pull/29494 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
2019-09-06esm: make dynamic import work in the REPLBradley Farias
PR-URL: https://github.com/nodejs/node/pull/29437 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com>
2019-08-20esm: support loading data URLsBradley Farias
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-13module: add warning when import,export is detected in CJS contextGiorgos Ntemiris
This will allow users to know how to change their project to support ES modules. PR-URL: https://github.com/nodejs/node/pull/28950 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
2019-08-12module: pkg exports validations and fallbacksGuy Bedford
PR-URL: https://github.com/nodejs/node/pull/28949 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com>
2019-08-07module: refine package name validationGuy Bedford
PR-URL: https://github.com/nodejs/node/pull/28965 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-08-01module: exports error as MODULE_NOT_FOUNDGuy Bedford
PR-URL: https://github.com/nodejs/node/pull/28905 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-07-31module: unify package exports test for CJS and ESMJan Krems
Refs: https://github.com/nodejs/modules/issues/358 PR-URL: https://github.com/nodejs/node/pull/28831 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-07-23module: implement "exports" proposal for CommonJSJan Krems
Refs: https://github.com/jkrems/proposal-pkg-exports/issues/36 Refs: https://github.com/nodejs/node/pull/28568 PR-URL: https://github.com/nodejs/node/pull/28759 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
2019-07-20test: fix assertion argument order in test-esm-namespaceAlex Ramirez
PR-URL: https://github.com/nodejs/node/pull/28474 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-07-18esm: implement "pkg-exports" proposalGuy Bedford
Refs: https://github.com/jkrems/proposal-pkg-exports/issues/36 PR-URL: https://github.com/nodejs/node/pull/28568 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-05-22esm: remove experimental status from JSON modulesMyles Borins
The HTML spec has officially landed JSON Modules and as such I think we can move them out of the "experimental" status. They will still be behind the `--experimental-modules` flag until the entire esm implementation moves out of experimental. Refs: https://html.spec.whatwg.org/#creating-a-json-module-script PR-URL: https://github.com/nodejs/node/pull/27752 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-05-20esm: use correct error argumentscjihrig
ERR_UNKNOWN_FILE_EXTENSION expects a single argument. This commit fixes the argument count. PR-URL: https://github.com/nodejs/node/pull/27763 Fixes: https://github.com/nodejs/node/issues/27761 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
2019-05-17esm: --experimental-wasm-modules integration supportMyles Borins
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-14test: clearing require cache crashes esm loaderAntoine du HAMEL
This test shows the regression introduced in v11.4.0: clearing out the require.cache crashes node when using the `--experimental-modules` flag. Refs: https://github.com/nodejs/node/issues/25482 PR-URL: https://github.com/nodejs/node/pull/25491 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-05-13tools: force common be required before any other modulesZYSzys
PR-URL: https://github.com/nodejs/node/pull/27650 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-05-06tools: fix node-core/required-modules eslint ruleBen Noordhuis
Make the node-core/required-modules eslint rule smart enough to recognize that `import '../common/index.mjs'` in ESM files imports the mandatory 'common' module. PR-URL: https://github.com/nodejs/node/pull/27545 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-04-24test: fix ineffective error testsMasashi Hirano
Fix tests whether errors are thrown correctly because they are successful when error doesn't get thrown. PR-URL: https://github.com/nodejs/node/pull/27333 Fixes: https://github.com/nodejs/node/issues/26385 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-04-16esm: replace --entry-type with --input-typeGeoffrey Booth
New flag is for string input only PR-URL: https://github.com/nodejs/node/pull/27184 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Myles Borins <myles.borins@gmail.com>
2019-03-27esm: phase two of new esm implementationguybedford
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-27benchmark,doc,lib: capitalize more commentsRuben Bridgewater
PR-URL: https://github.com/nodejs/node/pull/26849 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2019-03-12process: make Symbol.toStringTag writableRuben Bridgewater
The ecosystem broke by making it non-writable, so this is a good intermediate fix. PR-URL: https://github.com/nodejs/node/pull/26488 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-10benchmark,doc,lib,test: capitalize commentsRuben Bridgewater
PR-URL: https://github.com/nodejs/node/pull/26483 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-03-03esm: process proxy Symbol.toString fixGuy Bedford
PR-URL: https://github.com/nodejs/node/pull/25963 Reviewed-By: John-David Dalton <john.david.dalton@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-27assert: adjust loose assertionsRuben Bridgewater
This changes the loose deep equal comparison by using the same logic as done in the strict deep equal comparison besides comparing primitives loosely, not comparing symbol properties and not comparing the prototype. `assert.deepEqual` is still commenly used and this is likely the biggest pitfall. Most changes are only minor and won't have a big impact besides likely fixing user expectations. PR-URL: https://github.com/nodejs/node/pull/25008 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2018-12-27test: refactor stdio handling in test-esm-cjs-mainRichard Lau
Set encoding on the stderr/stdout streams instead of calling data.toString(). Don't assume the complete expected messages arrive in a single event. PR-URL: https://github.com/nodejs/node/pull/25169 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2018-12-25test: refactor test-esm-namespace.mjsRich Trott
Remove unused `name` argument that is different from a subsequent `name` argument in a different but nearby function. This was mildly confusing to me at first, so hopefully this change clarifies things for others reading the test. PR-URL: https://github.com/nodejs/node/pull/25117 Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-18test: add signal check to test-esm-cjs-mainRich Trott
PR-URL: https://github.com/nodejs/node/pull/25073 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-15test: run eslint on test file and fix errorsRuben Bridgewater
This removes two entries from the eslint ignore file. One file does not exist anymore and the other one could easily be fixed. PR-URL: https://github.com/nodejs/node/pull/25009 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>