diff options
author | Guy Bedford <guybedford@gmail.com> | 2018-02-12 13:02:42 +0200 |
---|---|---|
committer | guybedford <guybedford@gmail.com> | 2018-02-14 16:35:12 +0200 |
commit | f1fc426cce9db230cb83866871f355afa0b92d3b (patch) | |
tree | c0c4bd08e279d6696d3b2542f8ab62d713d2a61d /test/fixtures | |
parent | 0e7b61229aa602e55c5fb034a63d7da97eecff3b (diff) | |
download | android-node-v8-f1fc426cce9db230cb83866871f355afa0b92d3b.tar.gz android-node-v8-f1fc426cce9db230cb83866871f355afa0b92d3b.tar.bz2 android-node-v8-f1fc426cce9db230cb83866871f355afa0b92d3b.zip |
module: support main w/o extension, pjson cache
This adds support for ensuring that the top-level main into Node is
supported loading when it has no extension for backwards-compat with
NodeJS bin workflows.
In addition package.json caching is implemented in the module lookup
process.
PR-URL: https://github.com/nodejs/node/pull/18728
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'test/fixtures')
-rw-r--r-- | test/fixtures/es-module-loaders/example-loader.mjs | 5 | ||||
-rw-r--r-- | test/fixtures/es-module-loaders/js-loader.mjs | 6 | ||||
-rw-r--r-- | test/fixtures/es-modules/noext | 1 |
3 files changed, 10 insertions, 2 deletions
diff --git a/test/fixtures/es-module-loaders/example-loader.mjs b/test/fixtures/es-module-loaders/example-loader.mjs index 771273a8d8..acb4486edc 100644 --- a/test/fixtures/es-module-loaders/example-loader.mjs +++ b/test/fixtures/es-module-loaders/example-loader.mjs @@ -8,7 +8,10 @@ const builtins = new Set( ); const JS_EXTENSIONS = new Set(['.js', '.mjs']); -export function resolve(specifier, parentModuleURL/*, defaultResolve */) { +const baseURL = new url.URL('file://'); +baseURL.pathname = process.cwd() + '/'; + +export function resolve(specifier, parentModuleURL = baseURL /*, defaultResolve */) { if (builtins.has(specifier)) { return { url: specifier, diff --git a/test/fixtures/es-module-loaders/js-loader.mjs b/test/fixtures/es-module-loaders/js-loader.mjs index 79d9774c1d..2173b0b503 100644 --- a/test/fixtures/es-module-loaders/js-loader.mjs +++ b/test/fixtures/es-module-loaders/js-loader.mjs @@ -3,7 +3,11 @@ const builtins = new Set( Object.keys(process.binding('natives')).filter(str => /^(?!(?:internal|node|v8)\/)/.test(str)) ) -export function resolve (specifier, base) { + +const baseURL = new _url.URL('file://'); +baseURL.pathname = process.cwd() + '/'; + +export function resolve (specifier, base = baseURL) { if (builtins.has(specifier)) { return { url: specifier, diff --git a/test/fixtures/es-modules/noext b/test/fixtures/es-modules/noext new file mode 100644 index 0000000000..f21c9bee6d --- /dev/null +++ b/test/fixtures/es-modules/noext @@ -0,0 +1 @@ +exports.cjs = true;
\ No newline at end of file |