@@ -101,6 +101,7 @@ describe('--experimental-detect-module', { concurrency: true }, () => {
101
101
] ) {
102
102
it ( testName , async ( ) => {
103
103
const { stdout, stderr, code, signal } = await spawnPromisified ( process . execPath , [
104
+ '--no-warnings' ,
104
105
'--experimental-detect-module' ,
105
106
entryPath ,
106
107
] ) ;
@@ -142,6 +143,7 @@ describe('--experimental-detect-module', { concurrency: true }, () => {
142
143
] ) {
143
144
it ( testName , async ( ) => {
144
145
const { stdout, stderr, code, signal } = await spawnPromisified ( process . execPath , [
146
+ '--no-warnings' ,
145
147
'--experimental-detect-module' ,
146
148
entryPath ,
147
149
] ) ;
@@ -291,6 +293,7 @@ describe('--experimental-detect-module', { concurrency: true }, () => {
291
293
292
294
it ( 'permits declaration of CommonJS module variables' , async ( ) => {
293
295
const { stdout, stderr, code, signal } = await spawnPromisified ( process . execPath , [
296
+ '--no-warnings' ,
294
297
'--experimental-detect-module' ,
295
298
fixtures . path ( 'es-modules/package-without-type/commonjs-wrapper-variables.js' ) ,
296
299
] ) ;
@@ -327,6 +330,48 @@ describe('--experimental-detect-module', { concurrency: true }, () => {
327
330
strictEqual ( signal , null ) ;
328
331
} ) ;
329
332
} ) ;
333
+
334
+ describe ( 'warn about typeless packages for .js files with ESM syntax' , { concurrency : true } , ( ) => {
335
+ for ( const { testName, entryPath } of [
336
+ {
337
+ testName : 'warns for ESM syntax in a .js entry point in a typeless package' ,
338
+ entryPath : fixtures . path ( 'es-modules/package-without-type/module.js' ) ,
339
+ } ,
340
+ {
341
+ testName : 'warns for ESM syntax in a .js file imported by a CommonJS entry point in a typeless package' ,
342
+ entryPath : fixtures . path ( 'es-modules/package-without-type/imports-esm.js' ) ,
343
+ } ,
344
+ {
345
+ testName : 'warns for ESM syntax in a .js file imported by an ESM entry point in a typeless package' ,
346
+ entryPath : fixtures . path ( 'es-modules/package-without-type/imports-esm.mjs' ) ,
347
+ } ,
348
+ ] ) {
349
+ it ( testName , async ( ) => {
350
+ const { stdout, stderr, code, signal } = await spawnPromisified ( process . execPath , [
351
+ '--experimental-detect-module' ,
352
+ entryPath ,
353
+ ] ) ;
354
+
355
+ match ( stderr , / M O D U L E _ T Y P E L E S S _ P A C K A G E _ J S O N / ) ;
356
+ strictEqual ( stdout , 'executed\n' ) ;
357
+ strictEqual ( code , 0 ) ;
358
+ strictEqual ( signal , null ) ;
359
+ } ) ;
360
+ }
361
+
362
+ it ( 'warns only once for a package.json that affects multiple files' , async ( ) => {
363
+ const { stdout, stderr, code, signal } = await spawnPromisified ( process . execPath , [
364
+ '--experimental-detect-module' ,
365
+ fixtures . path ( 'es-modules/package-without-type/detected-as-esm.js' ) ,
366
+ ] ) ;
367
+
368
+ match ( stderr , / M O D U L E _ T Y P E L E S S _ P A C K A G E _ J S O N / ) ;
369
+ strictEqual ( stderr . match ( / M O D U L E _ T Y P E L E S S _ P A C K A G E _ J S O N / g) . length , 1 ) ;
370
+ strictEqual ( stdout , 'executed\nexecuted\n' ) ;
371
+ strictEqual ( code , 0 ) ;
372
+ strictEqual ( signal , null ) ;
373
+ } ) ;
374
+ } ) ;
330
375
} ) ;
331
376
332
377
// Validate temporarily disabling `--abort-on-uncaught-exception`
0 commit comments