Skip to content

Commit

Permalink
module: unflag resolve self
Browse files Browse the repository at this point in the history
PR-URL: #31002
Reviewed-By: Myles Borins <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Jan Krems <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
guybedford authored and BridgeAR committed Jan 2, 2020
1 parent bf7265f commit c7f328f
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 32 deletions.
11 changes: 1 addition & 10 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ added: v8.5.0
-->

Enable latest experimental modules features (currently
`--experimental-conditional-exports` and `--experimental-resolve-self`).
`--experimental-conditional-exports`).

### `--experimental-policy`
<!-- YAML
Expand All @@ -201,14 +201,6 @@ added: v11.8.0

Enable experimental diagnostic report feature.

### `--experimental-resolve-self`
<!-- YAML
added: v13.1.0
-->

Enable experimental support for a package using `require` or `import` to load
itself.

### `--experimental-specifier-resolution=mode`
<!-- YAML
added: v13.4.0
Expand Down Expand Up @@ -1091,7 +1083,6 @@ Node.js options that are allowed are:
* `--experimental-policy`
* `--experimental-repl-await`
* `--experimental-report`
* `--experimental-resolve-self`
* `--experimental-specifier-resolution`
* `--experimental-vm-modules`
* `--experimental-wasi-unstable-preview1`
Expand Down
3 changes: 0 additions & 3 deletions doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ Enable experimental
.Sy diagnostic report
feature.
.
.It Fl -experimental-resolve-self
Enable experimental support for a package to load itself.
.
.It Fl -experimental-vm-modules
Enable experimental ES module support in VM module.
.
Expand Down
4 changes: 1 addition & 3 deletions lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ const { getOptionValue } = require('internal/options');
const enableSourceMaps = getOptionValue('--enable-source-maps');
const preserveSymlinks = getOptionValue('--preserve-symlinks');
const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main');
const experimentalSelf = getOptionValue('--experimental-resolve-self');
const experimentalConditionalExports =
getOptionValue('--experimental-conditional-exports');
const manifest = getOptionValue('--experimental-policy') ?
Expand Down Expand Up @@ -432,10 +431,9 @@ function resolveBasePath(basePath, exts, isMain, trailingSlash, request) {
}

function trySelf(parentPath, isMain, request) {
if (!experimentalSelf) {
if (!experimentalConditionalExports) {
return false;
}

const { data: pkg, path: basePath } = readPackageScope(parentPath) || {};
if (!pkg || 'exports' in pkg === false) return false;
if (typeof pkg.name !== 'string') return false;
Expand Down
3 changes: 0 additions & 3 deletions src/module_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1153,9 +1153,6 @@ Maybe<URL> ResolveSelf(Environment* env,
const std::string& pkg_name,
const std::string& pkg_subpath,
const URL& base) {
if (!env->options()->experimental_resolve_self) {
return Nothing<URL>();
}
const PackageConfig* pcfg;
if (GetPackageScopeConfig(env, base, base).To(&pcfg) &&
pcfg->exists == Exists::Yes) {
Expand Down
7 changes: 1 addition & 6 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,11 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
&EnvironmentOptions::userland_loader,
kAllowedInEnvironment);
AddAlias("--loader", "--experimental-loader");
AddAlias("--experimental-modules", { "--experimental-conditional-exports",
"--experimental-resolve-self" });
AddAlias("--experimental-modules", { "--experimental-conditional-exports" });
AddOption("--experimental-conditional-exports",
"experimental support for conditional exports targets",
&EnvironmentOptions::experimental_conditional_exports,
kAllowedInEnvironment);
AddOption("--experimental-resolve-self",
"experimental support for require/import of the current package",
&EnvironmentOptions::experimental_resolve_self,
kAllowedInEnvironment);
AddOption("--experimental-wasm-modules",
"experimental ES Module support for webassembly modules",
&EnvironmentOptions::experimental_wasm_modules,
Expand Down
1 change: 0 additions & 1 deletion src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class EnvironmentOptions : public Options {
bool enable_source_maps = false;
bool experimental_conditional_exports = false;
bool experimental_json_modules = false;
bool experimental_resolve_self = false;
std::string experimental_specifier_resolution;
std::string es_module_specifier_resolution;
bool experimental_wasm_modules = false;
Expand Down
7 changes: 1 addition & 6 deletions test/es-module/test-esm-exports.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,7 @@ function assertIncludes(actual, expected) {
'--experimental-conditional-exports',
'/es-modules/conditional-exports.js',
'Conditional exports',
],
[
'--experimental-resolve-self',
'/node_modules/pkgexports/resolve-self.js',
'Package name self resolution',
],
]
].forEach(([flag, file, message]) => {
const child = spawn(process.execPath, [flag, path(file)]);

Expand Down

0 comments on commit c7f328f

Please sign in to comment.