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: {
|
transform: {
|
||||||
react: {
|
react: {
|
||||||
|
runtime: 'automatic',
|
||||||
pragma: 'React.createElement',
|
pragma: 'React.createElement',
|
||||||
pragmaFrag: 'React.Fragment',
|
pragmaFrag: 'React.Fragment',
|
||||||
throwIfNamespace: true,
|
throwIfNamespace: true,
|
||||||
@ -61,6 +62,7 @@ module.exports = function (task) {
|
|||||||
},
|
},
|
||||||
transform: {
|
transform: {
|
||||||
react: {
|
react: {
|
||||||
|
runtime: 'automatic',
|
||||||
pragma: 'React.createElement',
|
pragma: 'React.createElement',
|
||||||
pragmaFrag: 'React.Fragment',
|
pragmaFrag: 'React.Fragment',
|
||||||
throwIfNamespace: true,
|
throwIfNamespace: true,
|
||||||
@ -72,22 +74,26 @@ module.exports = function (task) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const swcOptions = server ? swcServerOptions : swcClientOptions
|
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
|
// Using `outDir` and `baseUrl` build a relative path from `outDir` to
|
||||||
// the `baseUrl` path for source maps
|
// the `baseUrl` path for source maps
|
||||||
const filePath = path.join(file.dir, file.base)
|
|
||||||
const basePath = path.join(__dirname, baseUrl)
|
const basePath = path.join(__dirname, baseUrl)
|
||||||
const relativeFilePath = path.relative(basePath, filePath)
|
const relativeFilePath = path.relative(basePath, filePath)
|
||||||
const fullFilePath = path.join(__dirname, filePath)
|
const fullFilePath = path.join(__dirname, filePath)
|
||||||
const distFilePath = path.dirname(
|
const distFilePath = path.dirname(
|
||||||
path.join(__dirname, outDir, relativeFilePath)
|
path.join(__dirname, outDir, relativeFilePath)
|
||||||
)
|
)
|
||||||
const options = {
|
|
||||||
filename: filePath,
|
options.sourceFileName = path.relative(distFilePath, fullFilePath)
|
||||||
sourceMaps: true,
|
|
||||||
sourceFileName: path.relative(distFilePath, fullFilePath),
|
|
||||||
...swcOptions,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const output = yield transform(file.data.toString('utf-8'), options)
|
const output = yield transform(file.data.toString('utf-8'), options)
|
||||||
const ext = path.extname(file.base)
|
const ext = path.extname(file.base)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user