mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 07:26:59 +00:00
Update swc plugin to include jsx import
This commit is contained in:
parent
1a352df8ab
commit
0306064a81
@ -33,6 +33,7 @@ module.exports = function (task) {
|
||||
},
|
||||
transform: {
|
||||
react: {
|
||||
runtime: 'automatic',
|
||||
pragma: 'React.createElement',
|
||||
pragmaFrag: 'React.Fragment',
|
||||
throwIfNamespace: true,
|
||||
@ -61,6 +62,7 @@ module.exports = function (task) {
|
||||
},
|
||||
transform: {
|
||||
react: {
|
||||
runtime: 'automatic',
|
||||
pragma: 'React.createElement',
|
||||
pragmaFrag: 'React.Fragment',
|
||||
throwIfNamespace: true,
|
||||
@ -72,22 +74,26 @@ module.exports = function (task) {
|
||||
}
|
||||
|
||||
const swcOptions = server ? swcServerOptions : swcClientOptions
|
||||
const filePath = path.join(file.dir, file.base)
|
||||
const options = {
|
||||
filename: filePath,
|
||||
sourceMaps: false,
|
||||
...swcOptions,
|
||||
}
|
||||
|
||||
if (options.sourceMaps && !options.sourceFileName) {
|
||||
// Using `outDir` and `baseUrl` build a relative path from `outDir` to
|
||||
// the `baseUrl` path for source maps
|
||||
const filePath = path.join(file.dir, file.base)
|
||||
const basePath = path.join(__dirname, baseUrl)
|
||||
const relativeFilePath = path.relative(basePath, filePath)
|
||||
const fullFilePath = path.join(__dirname, filePath)
|
||||
const distFilePath = path.dirname(
|
||||
path.join(__dirname, outDir, relativeFilePath)
|
||||
)
|
||||
const options = {
|
||||
filename: filePath,
|
||||
sourceMaps: true,
|
||||
sourceFileName: path.relative(distFilePath, fullFilePath),
|
||||
...swcOptions,
|
||||
|
||||
options.sourceFileName = path.relative(distFilePath, fullFilePath)
|
||||
}
|
||||
|
||||
const output = yield transform(file.data.toString('utf-8'), options)
|
||||
const ext = path.extname(file.base)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user