mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: enable ts-esm support by default (#12658)
This commit is contained in:
parent
cf643ff04c
commit
4d3d0e2bda
@ -238,9 +238,9 @@ async function launchDockerContainer(): Promise<() => Promise<void>> {
|
||||
function restartWithExperimentalTsEsm(configFile: string | null): boolean {
|
||||
if (!configFile)
|
||||
return false;
|
||||
if (!process.env.PW_EXPERIMENTAL_TS_ESM)
|
||||
if (process.env.PW_DISABLE_TS_ESM)
|
||||
return false;
|
||||
if (process.env.PW_EXPERIMENTAL_TS_ESM_ON)
|
||||
if (process.env.PW_TS_ESM_ON)
|
||||
return false;
|
||||
if (!configFile.endsWith('.ts'))
|
||||
return false;
|
||||
@ -251,7 +251,7 @@ function restartWithExperimentalTsEsm(configFile: string | null): boolean {
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_OPTIONS,
|
||||
PW_EXPERIMENTAL_TS_ESM_ON: '1',
|
||||
PW_TS_ESM_ON: '1',
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -54,10 +54,10 @@ sourceMapSupport.install({
|
||||
}
|
||||
});
|
||||
|
||||
function calculateCachePath(content: string, filePath: string): string {
|
||||
function calculateCachePath(content: string, filePath: string, isModule: boolean): string {
|
||||
const hash = crypto.createHash('sha1')
|
||||
.update(process.env.PW_TEST_SOURCE_TRANSFORM || '')
|
||||
.update(process.env.PW_EXPERIMENTAL_TS_ESM ? 'esm' : 'no_esm')
|
||||
.update(isModule ? 'esm' : 'no_esm')
|
||||
.update(content)
|
||||
.update(filePath)
|
||||
.update(String(version))
|
||||
@ -134,7 +134,7 @@ export function transformHook(code: string, filename: string, isModule = false):
|
||||
if (!isTypeScript && !hasPreprocessor)
|
||||
return code;
|
||||
|
||||
const cachePath = calculateCachePath(code, filename);
|
||||
const cachePath = calculateCachePath(code, filename, isModule);
|
||||
const codePath = cachePath + '.js';
|
||||
const sourceMapPath = cachePath + '.map';
|
||||
sourceMaps.set(filename, sourceMapPath);
|
||||
|
||||
@ -260,9 +260,7 @@ test('should import esm from ts when package.json has type module in experimenta
|
||||
'b.ts': `
|
||||
export const foo: string = 'foo';
|
||||
`
|
||||
}, {}, {
|
||||
PW_EXPERIMENTAL_TS_ESM: true
|
||||
});
|
||||
}, {});
|
||||
|
||||
expect(result.exitCode).toBe(0);
|
||||
});
|
||||
@ -278,9 +276,7 @@ test('should propagate subprocess exit code in experimental mode @esm', async ({
|
||||
expect(1).toBe(2);
|
||||
});
|
||||
`,
|
||||
}, {}, {
|
||||
PW_EXPERIMENTAL_TS_ESM: true
|
||||
});
|
||||
}, {});
|
||||
|
||||
expect(result.exitCode).toBe(1);
|
||||
});
|
||||
|
||||
@ -195,9 +195,7 @@ test('should respect path resolver in experimental mode @esm', async ({ runInlin
|
||||
'foo/bar/util/b.ts': `
|
||||
export const foo: string = 'foo';
|
||||
`,
|
||||
}, {}, {
|
||||
PW_EXPERIMENTAL_TS_ESM: true
|
||||
});
|
||||
}, {});
|
||||
|
||||
expect(result.exitCode).toBe(0);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user