mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-11 04:30:17 +03:00
fix(transform): allow import attributes always (#33527)
This commit is contained in:
parent
503f74da90
commit
d5ebe285c1
@ -27,7 +27,9 @@ import traverseFunction from '@babel/traverse';
|
|||||||
export const traverse = traverseFunction;
|
export const traverse = traverseFunction;
|
||||||
|
|
||||||
function babelTransformOptions(isTypeScript: boolean, isModule: boolean, pluginsPrologue: [string, any?][], pluginsEpilogue: [string, any?][]): TransformOptions {
|
function babelTransformOptions(isTypeScript: boolean, isModule: boolean, pluginsPrologue: [string, any?][], pluginsEpilogue: [string, any?][]): TransformOptions {
|
||||||
const plugins = [];
|
const plugins = [
|
||||||
|
[require('@babel/plugin-syntax-import-attributes'), { deprecatedAssertSyntax: true }],
|
||||||
|
];
|
||||||
|
|
||||||
if (isTypeScript) {
|
if (isTypeScript) {
|
||||||
plugins.push(
|
plugins.push(
|
||||||
@ -45,7 +47,6 @@ 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
|
||||||
(
|
(
|
||||||
|
@ -45,9 +45,15 @@ test('should support import attributes', async ({ runInlineTest }) => {
|
|||||||
'package.json': JSON.stringify({ type: 'module', foo: 'bar' }),
|
'package.json': JSON.stringify({ type: 'module', foo: 'bar' }),
|
||||||
'a.test.ts': `
|
'a.test.ts': `
|
||||||
import config from './package.json' with { type: 'json' };
|
import config from './package.json' with { type: 'json' };
|
||||||
|
import configFooFromUtils from './utils.js'
|
||||||
console.log('imported value (test): ' + config.foo);
|
console.log('imported value (test): ' + config.foo);
|
||||||
import { test, expect } from '@playwright/test';
|
import { test, expect } from '@playwright/test';
|
||||||
|
expect(configFooFromUtils.foo).toBe('bar');
|
||||||
test('pass', async () => {});
|
test('pass', async () => {});
|
||||||
|
`,
|
||||||
|
'utils.js': `
|
||||||
|
import config from './package.json' with { type: 'json' };
|
||||||
|
export default config;
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
expect(result.exitCode).toBe(0);
|
expect(result.exitCode).toBe(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user