11cb0ef41Sopenharmony_ciimport '../common/index.mjs'; 21cb0ef41Sopenharmony_ciimport { rejects } from 'assert'; 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst fixtureBase = '../fixtures/es-modules/package-cjs-named-error'; 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst errTemplate = (specifier, name, namedImports) => 71cb0ef41Sopenharmony_ci `Named export '${name}' not found. The requested module` + 81cb0ef41Sopenharmony_ci ` '${specifier}' is a CommonJS module, which may not support ` + 91cb0ef41Sopenharmony_ci 'all module.exports as named exports.\nCommonJS modules can ' + 101cb0ef41Sopenharmony_ci 'always be imported via the default export, for example using:' + 111cb0ef41Sopenharmony_ci `\n\nimport pkg from '${specifier}';\n` + (namedImports ? 121cb0ef41Sopenharmony_ci `const ${namedImports} = pkg;\n` : ''); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst expectedWithoutExample = errTemplate('./fail.cjs', 'comeOn'); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciconst expectedRelative = errTemplate('./fail.cjs', 'comeOn', '{ comeOn }'); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ciconst expectedRenamed = errTemplate('./fail.cjs', 'comeOn', 191cb0ef41Sopenharmony_ci '{ comeOn: comeOnRenamed }'); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciconst expectedPackageHack = 221cb0ef41Sopenharmony_ci errTemplate('./json-hack/fail.js', 'comeOn', '{ comeOn }'); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciconst expectedBare = errTemplate('deep-fail', 'comeOn', '{ comeOn }'); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_cirejects(async () => { 271cb0ef41Sopenharmony_ci await import(`${fixtureBase}/single-quote.mjs`); 281cb0ef41Sopenharmony_ci}, { 291cb0ef41Sopenharmony_ci name: 'SyntaxError', 301cb0ef41Sopenharmony_ci message: expectedRelative 311cb0ef41Sopenharmony_ci}, 'should support relative specifiers with single quotes'); 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_cirejects(async () => { 341cb0ef41Sopenharmony_ci await import(`${fixtureBase}/double-quote.mjs`); 351cb0ef41Sopenharmony_ci}, { 361cb0ef41Sopenharmony_ci name: 'SyntaxError', 371cb0ef41Sopenharmony_ci message: expectedRelative 381cb0ef41Sopenharmony_ci}, 'should support relative specifiers with double quotes'); 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_cirejects(async () => { 411cb0ef41Sopenharmony_ci await import(`${fixtureBase}/renamed-import.mjs`); 421cb0ef41Sopenharmony_ci}, { 431cb0ef41Sopenharmony_ci name: 'SyntaxError', 441cb0ef41Sopenharmony_ci message: expectedRenamed 451cb0ef41Sopenharmony_ci}, 'should correctly format named imports with renames'); 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_cirejects(async () => { 481cb0ef41Sopenharmony_ci await import(`${fixtureBase}/multi-line.mjs`); 491cb0ef41Sopenharmony_ci}, { 501cb0ef41Sopenharmony_ci name: 'SyntaxError', 511cb0ef41Sopenharmony_ci message: expectedWithoutExample, 521cb0ef41Sopenharmony_ci}, 'should correctly format named imports across multiple lines'); 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_cirejects(async () => { 551cb0ef41Sopenharmony_ci await import(`${fixtureBase}/json-hack.mjs`); 561cb0ef41Sopenharmony_ci}, { 571cb0ef41Sopenharmony_ci name: 'SyntaxError', 581cb0ef41Sopenharmony_ci message: expectedPackageHack 591cb0ef41Sopenharmony_ci}, 'should respect recursive package.json for module type'); 601cb0ef41Sopenharmony_ci 611cb0ef41Sopenharmony_cirejects(async () => { 621cb0ef41Sopenharmony_ci await import(`${fixtureBase}/bare-import-single.mjs`); 631cb0ef41Sopenharmony_ci}, { 641cb0ef41Sopenharmony_ci name: 'SyntaxError', 651cb0ef41Sopenharmony_ci message: expectedBare 661cb0ef41Sopenharmony_ci}, 'should support bare specifiers with single quotes'); 671cb0ef41Sopenharmony_ci 681cb0ef41Sopenharmony_cirejects(async () => { 691cb0ef41Sopenharmony_ci await import(`${fixtureBase}/bare-import-double.mjs`); 701cb0ef41Sopenharmony_ci}, { 711cb0ef41Sopenharmony_ci name: 'SyntaxError', 721cb0ef41Sopenharmony_ci message: expectedBare 731cb0ef41Sopenharmony_ci}, 'should support bare specifiers with double quotes'); 741cb0ef41Sopenharmony_ci 751cb0ef41Sopenharmony_cirejects(async () => { 761cb0ef41Sopenharmony_ci await import(`${fixtureBase}/escaped-single-quote.mjs`); 771cb0ef41Sopenharmony_ci}, /import pkg from '\.\/oh'no\.cjs'/, 'should support relative specifiers with escaped single quote'); 78