Skip to content
This repository was archived by the owner on Apr 16, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
esm: rename internal module type strings to match public api for --type
  • Loading branch information
GeoffreyBooth authored and nodejs-ci committed Mar 7, 2019
commit 85df5113e06e7c4bc9cf03c72c802e61a7f0afb7
2 changes: 1 addition & 1 deletion lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ E('ERR_INVALID_TUPLE', '%s must be an iterable %s tuple', TypeError);
E('ERR_INVALID_TYPE_EXTENSION', '%s extension is not supported for --type=%s',
TypeError);
E('ERR_INVALID_TYPE_FLAG',
'Type flag must be one of "esm", "commonjs". Received --type=%s',
'Type flag must be one of "module", "commonjs". Received --type=%s',
TypeError);
E('ERR_INVALID_URI', 'URI malformed', URIError);
E('ERR_INVALID_URL', 'Invalid URL: %s', TypeError);
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/main/check_syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function checkSyntax(source, filename) {
} else {
const resolve = require('internal/modules/esm/default_resolve');
const { format } = resolve(pathToFileURL(filename).toString());
isModule = format === 'esm';
isModule = format === 'module';
}
if (isModule) {
const { ModuleWrap } = internalBinding('module_wrap');
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ Module.runMain = function() {
const fileURL = pathToFileURL(process.argv[1]);
const resolve = require('internal/modules/esm/default_resolve');
const { format } = resolve(fileURL.toString());
const isModule = format === 'esm';
const isModule = format === 'module';
if ((isModule && asyncESM.typeFlag === 'commonjs') ||
(!isModule && asyncESM.typeFlag === 'module'))
throw new ERR_INVALID_TYPE_EXTENSION(ext, asyncESM.typeFlag);
Expand Down
18 changes: 9 additions & 9 deletions lib/internal/modules/esm/default_resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ const realpathCache = new Map();

const extensionFormatMap = {
'__proto__': null,
'.cjs': 'cjs',
'.js': 'esm',
'.mjs': 'esm'
'.cjs': 'commonjs',
'.js': 'module',
'.mjs': 'module'
};

const legacyExtensionFormatMap = {
'__proto__': null,
'.cjs': 'cjs',
'.js': 'cjs',
'.json': 'cjs',
'.mjs': 'esm',
'.node': 'cjs'
'.cjs': 'commonjs',
'.js': 'commonjs',
'.json': 'commonjs',
'.mjs': 'module',
'.node': 'commonjs'
};

function resolve(specifier, parentURL) {
Expand Down Expand Up @@ -65,7 +65,7 @@ function resolve(specifier, parentURL) {

if (!format) {
if (isMain)
format = legacy ? 'cjs' : 'esm';
format = legacy ? 'commonjs' : 'module';
else
throw new ERR_UNKNOWN_FILE_EXTENSION(fileURLToPath(url),
fileURLToPath(parentURL));
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/modules/esm/translators.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function importModuleDynamically(specifier, { url }) {
}

// Strategy for loading a standard JavaScript module
translators.set('esm', async function(url) {
translators.set('module', async function(url) {
const source = `${await readFileAsync(new URL(url))}`;
debug(`Translating StandardModule ${url}`);
const module = new ModuleWrap(stripShebang(source), url);
Expand All @@ -52,7 +52,7 @@ translators.set('esm', async function(url) {
// Strategy for loading a node-style CommonJS module
const isWindows = process.platform === 'win32';
const winSepRegEx = /\//g;
translators.set('cjs', async function(url, isMain) {
translators.set('commonjs', async function(url, isMain) {
debug(`Translating CJSModule ${url}`);
const pathname = internalURLModule.fileURLToPath(new URL(url));
const cached = this.cjsCache.get(url);
Expand Down