mirror of
				https://github.com/microsoft/playwright.git
				synced 2025-06-26 21:40:17 +00:00 
			
		
		
		
	chore: remove esm error interception, it only confuses users (#14829)
This commit is contained in:
		
							parent
							
								
									dcdd3c3cdb
								
							
						
					
					
						commit
						88664c39c9
					
				| @ -275,21 +275,6 @@ export class Loader { | |||||||
|       if (isModule) |       if (isModule) | ||||||
|         return await esmImport(); |         return await esmImport(); | ||||||
|       return require(file); |       return require(file); | ||||||
|     } catch (error) { |  | ||||||
|       if (error.code === 'ERR_MODULE_NOT_FOUND' && error.message.includes('Did you mean to import')) { |  | ||||||
|         const didYouMean = /Did you mean to import (.*)\?/.exec(error.message)?.[1]; |  | ||||||
|         if (didYouMean?.endsWith('.ts')) |  | ||||||
|           throw errorWithFile(file, 'Cannot import a typescript file from an esmodule.'); |  | ||||||
|       } |  | ||||||
|       if (error.code === 'ERR_UNKNOWN_FILE_EXTENSION' && error.message.includes('.ts')) { |  | ||||||
|         throw errorWithFile(file, `Cannot import a typescript file from an esmodule.\n${'='.repeat(80)}\nMake sure that:
 |  | ||||||
|   - you are using Node.js 16+, |  | ||||||
|   - your package.json contains "type": "module", |  | ||||||
|   - you are using TypeScript for playwright.config.ts. |  | ||||||
| ${'='.repeat(80)}\n`);
 |  | ||||||
|       } |  | ||||||
| 
 |  | ||||||
|       throw error; |  | ||||||
|     } finally { |     } finally { | ||||||
|       revertBabelRequire(); |       revertBabelRequire(); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -238,7 +238,7 @@ test('should fail to load ts from esm when package.json has type module', async | |||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   expect(result.exitCode).toBe(1); |   expect(result.exitCode).toBe(1); | ||||||
|   expect(result.output).toContain('Cannot import a typescript file from an esmodule'); |   expect(result.output).toContain('Unknown file extension ".ts"'); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| test('should filter stack trace for simple expect', async ({ runInlineTest }) => { | test('should filter stack trace for simple expect', async ({ runInlineTest }) => { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Pavel Feldman
						Pavel Feldman