Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

esm: scoped --type, cpp refactoring #57

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4e4add3
esm: remove .json support
guybedford Aug 28, 2018
e51b25b
esm: remove .node support
MylesBorins Sep 12, 2018
0416d3b
esm: remove .js support
MylesBorins Oct 2, 2018
4dfe731
esm: remove node specifier resolution algorithm
MylesBorins Oct 2, 2018
c8bbebe
doc: document minimal kernel
MylesBorins Oct 2, 2018
68a0551
esm: Remove --loader.
jdalton Oct 2, 2018
ac001a7
esm: minimal resolver spec and implementation refinements
guybedford Oct 24, 2018
07a7116
specify import file specifier resolution proposal
guybedford Nov 29, 2018
fedb9f0
irp type implementation
guybedford Jan 24, 2019
5b9c060
esm: top-level --type, -m flags, spec updates
guybedford Feb 10, 2019
6657f68
esm: implement top-level --type flag, type:esm -> type:module
guybedford Feb 11, 2019
1a8df02
esm: check for mismatch between --type and input file extension
GeoffreyBooth Feb 24, 2019
85df511
esm: rename internal module type strings to match public api for --type
GeoffreyBooth Feb 24, 2019
80a4ba4
esm: --type no longer overrides package.json; throw on conflict
GeoffreyBooth Feb 24, 2019
64963d3
esm: add -m alias for --type=module
GeoffreyBooth Feb 17, 2019
1acff8a
esm: tests for --type error cases
GeoffreyBooth Feb 25, 2019
a3ac35d
esm: include format mismatch errors in spec
guybedford Feb 26, 2019
3f5af33
esm: implement symlink handling in package scope
guybedford Feb 26, 2019
d3b7bbc
esm: merge both 'type mismatch' errors into one
GeoffreyBooth Feb 27, 2019
381762e
esm: tests for correctly detecting module types of symlinks
GeoffreyBooth Feb 27, 2019
7359c43
esm: unify type mismatch errors
guybedford Feb 27, 2019
724bf02
esm: fix errors for --type / "type" mismatches
GeoffreyBooth Feb 27, 2019
19ec40f
test: add additional fixtures and tests for irp
MylesBorins Feb 26, 2019
59cf1f4
misc: ci fixes for latest commits
guybedford Mar 5, 2019
c73a555
test: fixup symlinks test in windows
guybedford Mar 5, 2019
04892d5
esm: Revert "esm: Remove --loader."
guybedford Mar 4, 2019
4406f99
esm: add experimental warning for --loader
guybedford Mar 5, 2019
0237465
fixup: fix broken tests
MylesBorins Mar 6, 2019
47bdf9d
doc: esm flags, package scope and file extensions rules (wip)
GeoffreyBooth Mar 5, 2019
0f701a0
doc: esm features, differences/interoperability with commonjs
GeoffreyBooth Mar 6, 2019
80d6ab1
doc: package entry points in esm
GeoffreyBooth Mar 6, 2019
ecc07e2
doc: notes from call
GeoffreyBooth Mar 7, 2019
fcc8c86
doc: improve createRequire example
MylesBorins Mar 7, 2019
8de9da0
doc: updates from review
MylesBorins Mar 8, 2019
f6e1a43
doc: fixup describing "main" as package entry point
GeoffreyBooth Mar 8, 2019
bec588f
esm: add --es-module-specifier-resolution
MylesBorins Mar 5, 2019
4a95e44
esm: scoped --type, cpp refactoring
guybedford Mar 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ module.exports = {
{
files: [
'doc/api/esm.md',
'test/es-module/test-esm-type-flag.js',
'test/es-module/test-esm-type-flag-alias.js',
'*.mjs',
'test/es-module/test-esm-example-loader.js',
],
Expand Down
14 changes: 13 additions & 1 deletion doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,18 @@ added: v2.4.0

Track heap object allocations for heap snapshots.

### `-m`, `--type=type`

Used with `--experimental-modules`, this configures Node.js to interpret the
initial entry point as CommonJS or as an ES module.

Valid values are `"commonjs"` and `"module"`. The default is to infer from
the file extension and the `"type"` field in the nearest parent `package.json`.

Works for executing a file as well as `--eval`, `--print`, `STDIN`.

`-m` is an alias for `--type=module`.

### `--use-bundled-ca`, `--use-openssl-ca`
<!-- YAML
added: v6.11.0
Expand Down Expand Up @@ -899,7 +911,7 @@ greater than `4` (its current default value). For more information, see the
[debugger]: debugger.html
[debugging security implications]: https://nodejs.org/en/docs/guides/debugging-getting-started/#security-implications
[emit_warning]: process.html#process_process_emitwarning_warning_type_code_ctor
[experimental ECMAScript Module]: esm.html#esm_loader_hooks
[experimental ECMAScript Module]: esm.html#esm_experimental_loader_hooks
[libuv threadpool documentation]: http://docs.libuv.org/en/latest/threadpool.html
[remote code execution]: https://www.owasp.org/index.php/Code_Injection
[secureProtocol]: tls.html#tls_tls_createsecurecontext_options
45 changes: 34 additions & 11 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,11 @@ An invalid or unexpected value was passed in an options object.

An invalid or unknown file encoding was passed.

<a id="ERR_INVALID_PACKAGE_CONFIG"></a>
### ERR_INVALID_PACKAGE_CONFIG

An invalid `package.json` file was found which failed parsing.

<a id="ERR_INVALID_PERFORMANCE_MARK"></a>
### ERR_INVALID_PERFORMANCE_MARK

Expand Down Expand Up @@ -1452,26 +1457,19 @@ a `dynamicInstantiate` hook.
A `MessagePort` was found in the object passed to a `postMessage()` call,
but not provided in the `transferList` for that call.

<a id="ERR_MISSING_MODULE"></a>
### ERR_MISSING_MODULE

> Stability: 1 - Experimental

An [ES6 module][] could not be resolved.

<a id="ERR_MISSING_PLATFORM_FOR_WORKER"></a>
### ERR_MISSING_PLATFORM_FOR_WORKER

The V8 platform used by this instance of Node.js does not support creating
Workers. This is caused by lack of embedder support for Workers. In particular,
this error will not occur with standard builds of Node.js.

<a id="ERR_MODULE_RESOLUTION_LEGACY"></a>
### ERR_MODULE_RESOLUTION_LEGACY
<a id="ERR_MODULE_NOT_FOUND"></a>
### ERR_MODULE_NOT_FOUND

> Stability: 1 - Experimental

A failure occurred resolving imports in an [ES6 module][].
An [ESM module][] could not be resolved.

<a id="ERR_MULTIPLE_CALLBACK"></a>
### ERR_MULTIPLE_CALLBACK
Expand Down Expand Up @@ -2213,6 +2211,32 @@ A non-specific HTTP/2 error has occurred.
Used in the `repl` in case the old history file is used and an error occurred
while trying to read and parse it.

<a id="ERR_INVALID_REPL_TYPE"></a>
### ERR_INVALID_REPL_TYPE

> Stability: 1 - Experimental

The `--type=...` flag is not compatible with the Node.js REPL.

<a id="ERR_TYPE_MISMATCH"></a>
### ERR_TYPE_MISMATCH

> Stability: 1 - Experimental

The `--type=commonjs` flag was used to attempt to execute an `.mjs` file or
a `.js` file where the nearest parent `package.json` contains
`"type": "module"`; or
the `--type=module` flag was used to attempt to execute a `.cjs` file or
a `.js` file where the nearest parent `package.json` either lacks a `"type"`
field or contains `"type": "commonjs"`.

<a id="ERR_INVALID_TYPE_FLAG"></a>
### ERR_INVALID_TYPE_FLAG

> Stability: 1 - Experimental

An invalid `--type=...` flag value was provided.

<a id="ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK"></a>
#### ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK

Expand Down Expand Up @@ -2243,7 +2267,6 @@ size.
This `Error` is thrown when a read is attempted on a TTY `WriteStream`,
such as `process.stdout.on('data')`.


[`'uncaughtException'`]: process.html#process_event_uncaughtexception
[`--force-fips`]: cli.html#cli_force_fips
[`Class: assert.AssertionError`]: assert.html#assert_class_assert_assertionerror
Expand Down
Loading