-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add swc helpers alias in monorepo (#23)
* chore: add @swc/helpers alias in monorepo * chore: fix remove unncessary flags
- Loading branch information
Showing
6 changed files
with
84 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "lib3", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export async function answer() { | ||
return 42; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,62 @@ | ||
const rspack = require("@rspack/core"); | ||
const path = require("path"); | ||
/** @type {import('@rspack/cli').Configuration} */ | ||
const config = { | ||
entry: { | ||
main: "./src/index.jsx" | ||
}, | ||
resolve: { | ||
extensions: ["...", ".jsx"] | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.jsx$/, | ||
use: { | ||
loader: "builtin:swc-loader", | ||
options: { | ||
// Enable source map | ||
sourceMap: true, | ||
jsc: { | ||
parser: { | ||
syntax: "ecmascript", | ||
jsx: true | ||
}, | ||
externalHelpers: true, | ||
preserveAllComments: false, | ||
transform: { | ||
react: { | ||
runtime: "automatic", | ||
pragma: "React.createElement", | ||
pragmaFrag: "React.Fragment", | ||
throwIfNamespace: true, | ||
useBuiltins: false | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
type: "javascript/auto" | ||
}, | ||
{ | ||
test: /\.(png|svg|jpg)$/, | ||
type: "asset/resource" | ||
} | ||
] | ||
}, | ||
optimization: { | ||
minimize: false // Disabling minification because it takes too long on CI | ||
}, | ||
plugins: [ | ||
new rspack.HtmlRspackPlugin({ | ||
template: "./index.html" | ||
}) | ||
] | ||
entry: { | ||
main: "./src/index.jsx", | ||
}, | ||
resolve: { | ||
extensions: ["...", ".jsx"], | ||
alias: { | ||
"@swc/helpers": path.dirname( | ||
require.resolve("@swc/helpers/package.json") | ||
), | ||
}, | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(jsx|js)$/, | ||
use: { | ||
loader: "builtin:swc-loader", | ||
options: { | ||
// Enable source map | ||
sourceMap: true, | ||
target: "es5", | ||
jsc: { | ||
parser: { | ||
syntax: "ecmascript", | ||
jsx: true, | ||
}, | ||
externalHelpers: true, | ||
preserveAllComments: false, | ||
transform: { | ||
react: { | ||
runtime: "automatic", | ||
pragma: "React.createElement", | ||
pragmaFrag: "React.Fragment", | ||
throwIfNamespace: true, | ||
useBuiltins: false, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
type: "javascript/auto", | ||
}, | ||
{ | ||
test: /\.(png|svg|jpg)$/, | ||
type: "asset/resource", | ||
}, | ||
], | ||
}, | ||
optimization: { | ||
minimize: false, // Disabling minification because it takes too long on CI | ||
}, | ||
plugins: [ | ||
new rspack.HtmlRspackPlugin({ | ||
template: "./index.html", | ||
}), | ||
], | ||
}; | ||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
const {defineConfig } = require('@rspack/cli'); | ||
const path = require('path'); | ||
const { defineConfig } = require("@rspack/cli"); | ||
const path = require("path"); | ||
module.exports = defineConfig({ | ||
entry: { | ||
main: './src/index.ts', | ||
}, | ||
experiments: { | ||
rspackFuture: { | ||
newResolver:true | ||
} | ||
main: "./src/index.ts", | ||
}, | ||
resolve: { | ||
tsConfig: { | ||
references: 'auto', | ||
configFile:path.resolve(__dirname,'./tsconfig.json') | ||
} | ||
} | ||
references: "auto", | ||
configFile: path.resolve(__dirname, "./tsconfig.json"), | ||
}, | ||
}, | ||
}); |