chore: don't mask ESM error (#14628)

This commit is contained in:
Pavel Feldman 2022-06-03 15:28:53 -07:00 committed by GitHub
parent 9711e62882
commit c4b003a29a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 4 deletions

View File

@ -289,9 +289,6 @@ export class Loader {
${'='.repeat(80)}\n`);
}
if (error instanceof SyntaxError && error.message.includes('Cannot use import statement outside a module'))
throw errorWithFile(file, 'JavaScript files must end with .mjs to use import.');
throw error;
} finally {
revertBabelRequire();

View File

@ -175,7 +175,7 @@ test('should throw a nice error if a js file uses import', async ({ runInlineTes
});
expect(exitCode).toBe(1);
expect(output).toContain('a.spec.js');
expect(output).toContain('JavaScript files must end with .mjs to use import.');
expect(output).toContain('Cannot use import statement outside a module');
});
test('should load esm when package.json has type module', async ({ runInlineTest }) => {