chore: enable @babel/plugin-syntax-import-attributes all the time
This commit is contained in:
parent
cc302fa515
commit
c83ba0c8d4
|
|
@ -45,6 +45,7 @@ function babelTransformOptions(isTypeScript: boolean, isModule: boolean, plugins
|
||||||
[require('@babel/plugin-syntax-async-generators')],
|
[require('@babel/plugin-syntax-async-generators')],
|
||||||
[require('@babel/plugin-syntax-object-rest-spread')],
|
[require('@babel/plugin-syntax-object-rest-spread')],
|
||||||
[require('@babel/plugin-transform-export-namespace-from')],
|
[require('@babel/plugin-transform-export-namespace-from')],
|
||||||
|
[require('@babel/plugin-syntax-import-attributes'), { deprecatedAssertSyntax: true }],
|
||||||
[
|
[
|
||||||
// From https://github.com/G-Rath/babel-plugin-replace-ts-export-assignment/blob/8dfdca32c8aa428574b0cae341444fc5822f2dc6/src/index.ts
|
// From https://github.com/G-Rath/babel-plugin-replace-ts-export-assignment/blob/8dfdca32c8aa428574b0cae341444fc5822f2dc6/src/index.ts
|
||||||
(
|
(
|
||||||
|
|
@ -86,8 +87,6 @@ function babelTransformOptions(isTypeScript: boolean, isModule: boolean, plugins
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
} else {
|
|
||||||
plugins.push([require('@babel/plugin-syntax-import-attributes'), { deprecatedAssertSyntax: true }]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -150,3 +150,30 @@ test('should not transform external', async ({ runInlineTest }) => {
|
||||||
expect(result.exitCode).toBe(1);
|
expect(result.exitCode).toBe(1);
|
||||||
expect(result.output).toMatch(/(Cannot use import statement outside a module|require\(\) of ES Module .* not supported.)/);
|
expect(result.output).toMatch(/(Cannot use import statement outside a module|require\(\) of ES Module .* not supported.)/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should support import assertions', {
|
||||||
|
annotation: {
|
||||||
|
type: 'issue',
|
||||||
|
description: 'https://github.com/microsoft/playwright/issues/32659'
|
||||||
|
}
|
||||||
|
}, async ({ runInlineTest }) => {
|
||||||
|
const result = await runInlineTest({
|
||||||
|
'playwright.config.ts': `
|
||||||
|
import packageJSON from './package.json' assert { type: 'json' };
|
||||||
|
console.log('imported value: ' + packageJSON.foo);
|
||||||
|
export default { };
|
||||||
|
`,
|
||||||
|
'package.json': JSON.stringify({ foo: 'bar' }),
|
||||||
|
'a.esm.test.ts': `
|
||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
test('check project name', ({}, testInfo) => {
|
||||||
|
expect(1).toBe(1);
|
||||||
|
});
|
||||||
|
`
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.exitCode).toBe(0);
|
||||||
|
expect(result.passed).toBe(1);
|
||||||
|
expect(result.stdout).toContain('imported value: bar');
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue