Skip to content

Commit

Permalink
try using swc-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
kalsky committed Aug 19, 2024
1 parent bf1d709 commit 32a5dab
Show file tree
Hide file tree
Showing 5 changed files with 298 additions and 3 deletions.
18 changes: 18 additions & 0 deletions docusaurus-prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,24 @@ const config = {
additionalLanguages: ['bash', 'powershell'],
},
}),

webpack: {
jsLoader: (isServer) => ({
loader: require.resolve('swc-loader'),
options: {
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
target: 'es2017',
},
module: {
type: isServer ? 'commonjs' : 'es6',
},
},
}),
},
};

export default config;
18 changes: 18 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,24 @@ const config = {
additionalLanguages: ['bash', 'powershell'],
},
}),

webpack: {
jsLoader: (isServer) => ({
loader: require.resolve('swc-loader'),
options: {
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
target: 'es2017',
},
module: {
type: isServer ? 'commonjs' : 'es6',
},
},
}),
},
};

export default config;
216 changes: 215 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
"@docusaurus/preset-classic": "^3.5.2",
"@easyops-cn/docusaurus-search-local": "^0.44.5",
"@mdx-js/react": "^3.0.0",
"@swc/core": "^1.7.14",
"clsx": "^2.0.0",
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react-dom": "^18.0.0",
"swc-loader": "^0.2.6"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.5.2",
Expand Down
45 changes: 44 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2073,6 +2073,42 @@
"@svgr/plugin-jsx" "8.1.0"
"@svgr/plugin-svgo" "8.1.0"

"@swc/[email protected]":
version "1.7.14"
resolved "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.7.14.tgz"
integrity sha512-9iFvUnxG6FC3An5ogp5jbBfQuUmTTwy8KMB+ZddUoPB3NR1eV+Y9vOh/tfWcenSJbgOKDLgYC5D/b1mHAprsrQ==

"@swc/core@^1.2.147", "@swc/core@^1.7.14":
version "1.7.14"
resolved "https://registry.npmjs.org/@swc/core/-/core-1.7.14.tgz"
integrity sha512-9aeXeifnyuvc2pcuuhPQgVUwdpGEzZ+9nJu0W8/hNl/aESFsJGR5i9uQJRGu0atoNr01gK092fvmqMmQAPcKow==
dependencies:
"@swc/counter" "^0.1.3"
"@swc/types" "^0.1.12"
optionalDependencies:
"@swc/core-darwin-arm64" "1.7.14"
"@swc/core-darwin-x64" "1.7.14"
"@swc/core-linux-arm-gnueabihf" "1.7.14"
"@swc/core-linux-arm64-gnu" "1.7.14"
"@swc/core-linux-arm64-musl" "1.7.14"
"@swc/core-linux-x64-gnu" "1.7.14"
"@swc/core-linux-x64-musl" "1.7.14"
"@swc/core-win32-arm64-msvc" "1.7.14"
"@swc/core-win32-ia32-msvc" "1.7.14"
"@swc/core-win32-x64-msvc" "1.7.14"

"@swc/counter@^0.1.3":
version "0.1.3"
resolved "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz"
integrity sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==

"@swc/types@^0.1.12":
version "0.1.12"
resolved "https://registry.npmjs.org/@swc/types/-/types-0.1.12.tgz"
integrity sha512-wBJA+SdtkbFhHjTMYH+dEH1y4VpfGdAc2Kw/LK09i9bXd/K6j6PkDcFCEzb6iVfZMkPRrl/q0e3toqTAJdkIVA==
dependencies:
"@swc/counter" "^0.1.3"

"@szmarczak/http-timer@^5.0.1":
version "5.0.1"
resolved "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-5.0.1.tgz"
Expand Down Expand Up @@ -8066,6 +8102,13 @@ svgo@^3.0.2, svgo@^3.2.0:
csso "^5.0.5"
picocolors "^1.0.0"

swc-loader@^0.2.6:
version "0.2.6"
resolved "https://registry.npmjs.org/swc-loader/-/swc-loader-0.2.6.tgz"
integrity sha512-9Zi9UP2YmDpgmQVbyOPJClY0dwf58JDyDMQ7uRc4krmc72twNI2fvlBWHLqVekBpPc7h5NJkGVT1zNDxFrqhvg==
dependencies:
"@swc/counter" "^0.1.3"

tapable@^1.0.0:
version "1.1.3"
resolved "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz"
Expand Down Expand Up @@ -8508,7 +8551,7 @@ webpack-sources@^3.2.3:
resolved "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz"
integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==

"webpack@^4.0.0 || ^5.0.0", "webpack@^4.37.0 || ^5.0.0", webpack@^5.0.0, webpack@^5.1.0, webpack@^5.20.0, webpack@^5.88.1, "webpack@>= 4", "webpack@>=4.41.1 || 5.x", webpack@>=5, "webpack@3 || 4 || 5":
"webpack@^4.0.0 || ^5.0.0", "webpack@^4.37.0 || ^5.0.0", webpack@^5.0.0, webpack@^5.1.0, webpack@^5.20.0, webpack@^5.88.1, "webpack@>= 4", webpack@>=2, "webpack@>=4.41.1 || 5.x", webpack@>=5, "webpack@3 || 4 || 5":
version "5.93.0"
resolved "https://registry.npmjs.org/webpack/-/webpack-5.93.0.tgz"
integrity sha512-Y0m5oEY1LRuwly578VqluorkXbvXKh7U3rLoQCEO04M97ScRr44afGVkI0FQFsXzysk5OgFAxjZAb9rsGQVihA==
Expand Down

0 comments on commit 32a5dab

Please sign in to comment.