mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
3fb7426f83
Previously we assumed if `--experimental-detect-module` is true, then `--experimental-require-module` is true, which isn't the case, as the two can be enabled/disabled separately. This patch fixes the checks so `--no-experimental-require-module` is still effective when `--experimental-detect-module` is enabled. Drive-by: make the assertion messages more informative and remove obsolete TODO about allowing TLA in entrypoints handled by require(esm). PR-URL: https://github.com/nodejs/node/pull/55250 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
20 lines
718 B
JavaScript
20 lines
718 B
JavaScript
// Flags: --no-experimental-require-module
|
|
'use strict';
|
|
|
|
// Tests that --experimental-require-module is not implied by --experimental-detect-module
|
|
// and is checked independently.
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
// Check that require() still throws SyntaxError for an ambiguous module that's detected to be ESM.
|
|
// TODO(joyeecheung): now that --experimental-detect-module is unflagged, it makes more sense
|
|
// to either throw ERR_REQUIRE_ESM for require() of detected ESM instead, or add a hint about the
|
|
// use of require(esm) to the SyntaxError.
|
|
|
|
assert.throws(
|
|
() => require('../fixtures/es-modules/loose.js'),
|
|
{
|
|
name: 'SyntaxError',
|
|
message: /Unexpected token 'export'/
|
|
});
|