diff --git a/test/fixtures/json-import/foo.js b/test/fixtures/json-import/foo.js new file mode 100644 index 00000000..1fbac6fc --- /dev/null +++ b/test/fixtures/json-import/foo.js @@ -0,0 +1,2 @@ +import foo from './foo.json' with { type: 'json' }; +export { foo }; diff --git a/test/fixtures/json-import/foo.json b/test/fixtures/json-import/foo.json new file mode 100644 index 00000000..a834474a --- /dev/null +++ b/test/fixtures/json-import/foo.json @@ -0,0 +1,3 @@ +{ + "str": "bar" +} diff --git a/test/fixtures/json-import/json-import.ts b/test/fixtures/json-import/json-import.ts new file mode 100644 index 00000000..b68812ba --- /dev/null +++ b/test/fixtures/json-import/json-import.ts @@ -0,0 +1,2 @@ +import { foo } from './foo.js'; +console.log(foo.str); diff --git a/test/fixtures/json-import/tsconfig.json b/test/fixtures/json-import/tsconfig.json new file mode 100644 index 00000000..ffbdf7cd --- /dev/null +++ b/test/fixtures/json-import/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "NodeNext", + "moduleResolution": "nodenext", + "resolveJsonModule": true + } +} diff --git a/test/index.test.ts b/test/index.test.ts index 30d9b9ab..7f297995 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -111,3 +111,12 @@ it('useDefineForClassFields=false', async () => { // Ensure inline property is moved to constructor expect(code).toContain('this.inlineProperty = \'value\'') }) + +it('json-import', async () => { + await expect(rollup({ + input: fixture('json-import/json-import.ts'), + plugins: [ + swc.rollup(), + ], + })).rejects.toThrow(' x Expected \';\', got \'with\'') +})