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

Commit 79a19d6

Browse files
committed
fixup: s/type/entry-type impl
1 parent b4f73f9 commit 79a19d6

10 files changed

+26
-25
lines changed

lib/internal/errors.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ E('ERR_INVALID_PROTOCOL',
784784
E('ERR_INVALID_REPL_EVAL_CONFIG',
785785
'Cannot specify both "breakEvalOnSigint" and "eval" for REPL', TypeError);
786786
E('ERR_INVALID_REPL_TYPE',
787-
'Cannot specify --type for REPL', TypeError);
787+
'Cannot specify --entry-type for REPL', TypeError);
788788
E('ERR_INVALID_RETURN_PROPERTY', (input, name, prop, value) => {
789789
return `Expected a valid ${input} to be returned for the "${prop}" from the` +
790790
` "${name}" function but got ${value}.`;
@@ -816,7 +816,7 @@ E('ERR_INVALID_SYNC_FORK_INPUT',
816816
E('ERR_INVALID_THIS', 'Value of "this" must be of type %s', TypeError);
817817
E('ERR_INVALID_TUPLE', '%s must be an iterable %s tuple', TypeError);
818818
E('ERR_INVALID_TYPE_FLAG',
819-
'Type flag must be one of "module", "commonjs". Received --type=%s',
819+
'Type flag must be one of "module", "commonjs". Received --entry-type=%s',
820820
TypeError);
821821
E('ERR_INVALID_URI', 'URI malformed', URIError);
822822
E('ERR_INVALID_URL', 'Invalid URL: %s', TypeError);
@@ -958,12 +958,12 @@ E('ERR_TRANSFORM_WITH_LENGTH_0',
958958
E('ERR_TTY_INIT_FAILED', 'TTY initialization failed', SystemError);
959959
E('ERR_TYPE_MISMATCH', (filename, ext, typeFlag, conflict) => {
960960
const typeString =
961-
typeFlag === 'module' ? '--type=module' : '--type=commonjs';
962-
// --type mismatches file extension
961+
typeFlag === 'module' ? '--entry-type=module' : '--entry-type=commonjs';
962+
// --entry-type mismatches file extension
963963
if (conflict === 'extension')
964964
return `Extension ${ext} is not supported for ` +
965965
`${typeString} loading ${filename}`;
966-
// --type mismatches package.json "type"
966+
// --entry-type mismatches package.json "type"
967967
else if (conflict === 'scope')
968968
return `Cannot use ${typeString} because nearest parent package.json ` +
969969
((typeFlag === 'module') ?

lib/internal/main/repl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const { ERR_INVALID_REPL_TYPE } = require('internal/errors').codes;
1515

1616
prepareMainThreadExecution();
1717

18-
// --type flag not supported in REPL
18+
// --entry-type flag not supported in REPL
1919
if (require('internal/process/esm_loader').typeFlag) {
2020
throw ERR_INVALID_REPL_TYPE();
2121
}

lib/internal/modules/esm/default_resolve.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ function resolve(specifier, parentURL) {
8181
let format = extMap[ext];
8282

8383
if (isMain && asyncESM.typeFlag) {
84-
// Conflict between explicit extension (.mjs, .cjs) and --type
84+
// Conflict between explicit extension (.mjs, .cjs) and --entry-type
8585
if (ext === '.cjs' && asyncESM.typeFlag === 'module' ||
8686
ext === '.mjs' && asyncESM.typeFlag === 'commonjs') {
8787
throw new ERR_TYPE_MISMATCH(
8888
fileURLToPath(url), ext, asyncESM.typeFlag, 'extension');
8989
}
9090

91-
// Conflict between package scope type and --type
91+
// Conflict between package scope type and --entry-type
9292
if (ext === '.js') {
9393
if (type === TYPE_MODULE && asyncESM.typeFlag === 'commonjs' ||
9494
type === TYPE_COMMONJS && asyncESM.typeFlag === 'module') {

lib/internal/process/esm_loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const {
99
} = require('internal/errors').codes;
1010
const { emitExperimentalWarning } = require('internal/util');
1111

12-
const type = require('internal/options').getOptionValue('--type');
12+
const type = require('internal/options').getOptionValue('--entry-type');
1313
if (type && type !== 'commonjs' && type !== 'module')
1414
throw new ERR_INVALID_TYPE_FLAG(type);
1515
exports.typeFlag = type;

src/node_options.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ void EnvironmentOptions::CheckOptions(std::vector<std::string>* errors) {
108108
}
109109

110110
if (!module_type.empty() && !experimental_modules) {
111-
errors->push_back("--type requires --experimental-modules be enabled");
111+
errors->push_back("--entry-type requires"
112+
"--experimental-modules be enabled");
112113
}
113114

114115
if (experimental_json_modules && !experimental_modules) {
@@ -332,7 +333,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
332333
"show stack traces on process warnings",
333334
&EnvironmentOptions::trace_warnings,
334335
kAllowedInEnvironment);
335-
AddOption("--type",
336+
AddOption("--entry-type",
336337
"top-level module type name",
337338
&EnvironmentOptions::module_type,
338339
kAllowedInEnvironment);

test/es-module/test-esm-no-extension.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const entry = fixtures.path('/es-modules/noext-esm');
99

1010
const child = spawn(process.execPath, [
1111
'--experimental-modules',
12-
'--type=module',
12+
'--entry-type=module',
1313
entry
1414
]);
1515

test/es-module/test-esm-type-flag-errors.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ expect('', packageTypeModuleMain, 'package-type-module');
1919
expect('', packageTypeCommonJsMain, 'package-type-commonjs');
2020
expect('', packageWithoutTypeMain, 'package-without-type');
2121

22-
// Check that running with --type and no package.json "type" works
23-
expect('--type=commonjs', packageWithoutTypeMain, 'package-without-type');
24-
expect('--type=module', packageWithoutTypeMain, 'package-without-type');
22+
// Check that running with --entry-type and no package.json "type" works
23+
expect('--entry-type=commonjs', packageWithoutTypeMain, 'package-without-type');
24+
expect('--entry-type=module', packageWithoutTypeMain, 'package-without-type');
2525

26-
// Check that running with conflicting --type flags throws errors
27-
expect('--type=commonjs', mjsFile, 'ERR_TYPE_MISMATCH', true);
28-
expect('--type=module', cjsFile, 'ERR_TYPE_MISMATCH', true);
29-
expect('--type=commonjs', packageTypeModuleMain,
26+
// Check that running with conflicting --entry-type flags throws errors
27+
expect('--entry-type=commonjs', mjsFile, 'ERR_TYPE_MISMATCH', true);
28+
expect('--entry-type=module', cjsFile, 'ERR_TYPE_MISMATCH', true);
29+
expect('--entry-type=commonjs', packageTypeModuleMain,
3030
'ERR_TYPE_MISMATCH', true);
31-
expect('--type=module', packageTypeCommonJsMain,
31+
expect('--entry-type=module', packageTypeCommonJsMain,
3232
'ERR_TYPE_MISMATCH', true);
3333

3434
function expect(opt = '', inputFile, want, wantsError = false) {

test/es-module/test-esm-type-flag.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Flags: --experimental-modules --type=module
1+
// Flags: --experimental-modules --entry-type=module
22
/* eslint-disable node-core/required-modules */
33
import cjs from '../fixtures/baz.js';
44
import '../common/index.mjs';

test/parallel/test-cli-syntax-piped-bad.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ syntaxArgs.forEach(function(arg) {
3434
assert.strictEqual(c.status, 1);
3535
});
3636

37-
// Check --type=module
37+
// Check --entry-type=module
3838
syntaxArgs.forEach(function(arg) {
3939
const stdin = 'export var p = 5; var foo bar;';
4040
const c = spawnSync(
4141
node,
42-
['--experimental-modules', '--type=module', '--no-warnings', arg],
42+
['--experimental-modules', '--entry-type=module', '--no-warnings', arg],
4343
{ encoding: 'utf8', input: stdin }
4444
);
4545

test/parallel/test-cli-syntax-piped-good.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ syntaxArgs.forEach(function(arg) {
2525
assert.strictEqual(c.status, 0);
2626
});
2727

28-
// Check --type=module
28+
// Check --entry-type=module
2929
syntaxArgs.forEach(function(arg) {
3030
const stdin = 'export var p = 5; throw new Error("should not get run");';
3131
const c = spawnSync(
3232
node,
33-
['--experimental-modules', '--no-warnings', '--type=module', arg],
33+
['--experimental-modules', '--no-warnings', '--entry-type=module', arg],
3434
{ encoding: 'utf8', input: stdin }
3535
);
3636

0 commit comments

Comments
 (0)