Skip to content

Commit 33568ee

Browse files
authored
fix(register): enable keepImportAttributes in SWC options (#816)
1 parent 9037fc9 commit 33568ee

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

packages/core/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ function transformOption(path: string, options?: Options, jest = false): SwcOpti
6161
keepClassNames: opts.keepClassNames,
6262
paths: opts.paths,
6363
baseUrl: opts.baseUrl,
64+
experimental: {
65+
keepImportAttributes: true,
66+
},
6467
},
6568
minify: false,
6669
isModule: true,

packages/integrate-module/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { baz } from './subdirectory/index.mjs'
1616
import { Component } from './component.js'
1717
import { common } from './common.cjs'
1818
import './js-module.mjs'
19+
import pgkJson from '../package.json' assert { type: 'json' }
20+
import pgkJsonWith from '../package.json' with { type: 'json' }
1921

2022
const { foo: fooWithQuery } = await import(`./foo.mjs?q=${Date.now()}`)
2123

@@ -67,3 +69,8 @@ await test('resolve local cjs module', () => {
6769
await test('resolve commonjs module', () => {
6870
assert.equal(common, 'common')
6971
})
72+
73+
await test('resolve json file', () => {
74+
assert.equal(pgkJson.name, 'integrate-module')
75+
assert.equal(pgkJsonWith.name, 'integrate-module')
76+
})

0 commit comments

Comments
 (0)