diff options
author | Jan Krems <jan.krems@gmail.com> | 2019-08-20 06:59:25 +0300 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-10-28 09:08:02 +0300 |
commit | edfbee37271d288d5dca7a33f06b14ef704f599d (patch) | |
tree | 14e65ba276dc286840442cd10553de9d602546f5 /src/node_options.h | |
parent | 0d9ae1b8f62082ada91f032dbda200edf67d9646 (diff) |
module: resolve self-references
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>
Diffstat (limited to 'src/node_options.h')
-rw-r--r-- | src/node_options.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/node_options.h b/src/node_options.h index 61339ee4383..a4af15e3e00 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -103,6 +103,7 @@ class EnvironmentOptions : public Options { bool enable_source_maps = false; bool experimental_json_modules = false; bool experimental_modules = false; + bool experimental_resolve_self = false; std::string es_module_specifier_resolution; bool experimental_wasm_modules = false; std::string module_type; |