Skip to content

Commit 2087346

Browse files
committed
fix: build working dist
TypeStrong/ts-loader#1463 `transpileOnly: true` doesn't work `tsconfig.cjs.json` doesn't work Use `NormalModuleReplacementPlugin` as workaround
1 parent ee93606 commit 2087346

File tree

5 files changed

+97
-1377
lines changed

5 files changed

+97
-1377
lines changed

.depcheckrc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ ignores:
44
- '@swc/*'
55
- '@size-limit/*'
66
- '@types/*'
7+
- clean-webpack-plugin
78
- jest-*
89
- param-case
910
- pascal-case
1011
- semantic-release
12+
- source-map-loader
1113
- ts-jest
1214
- ts-loader
1315
- webpack-*

babel.config.mjs

-3
This file was deleted.

package.json

-4
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@
7474
"unpartial": "^0.7.3"
7575
},
7676
"devDependencies": {
77-
"@babel/plugin-transform-modules-commonjs": "^7.18.2",
78-
"@babel/preset-env": "^7.18.2",
79-
"@babel/preset-typescript": "^7.17.12",
8077
"@commitlint/cli": "^17.0.0",
8178
"@commitlint/config-conventional": "^17.0.0",
8279
"@semantic-release/changelog": "^6.0.1",
@@ -89,7 +86,6 @@
8986
"@types/jest": "^27.5.1",
9087
"@typescript-eslint/eslint-plugin": "^5.20.0",
9188
"@typescript-eslint/parser": "^5.23.0",
92-
"babel-loader": "^8.2.5",
9389
"clean-webpack-plugin": "^4.0.0",
9490
"depcheck": "^1.4.3",
9591
"eslint": "8.16.0",

webpack.config.cjs

+3-17
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,10 @@ module.exports = {
2020
loader: 'ts-loader',
2121
test: /\.ts$/,
2222
options: {
23-
configFile: 'tsconfig.cjs.json',
24-
transpileOnly: true
23+
configFile: 'tsconfig.esm.json',
24+
// transpileOnly: true
2525
}
2626
},
27-
// {
28-
// loader: 'babel-loader',
29-
// test: /\.js$/,
30-
// options:
31-
// {
32-
// presets: [
33-
// '@babel/preset-env',
34-
// '@babel/preset-typescript'
35-
// ],
36-
// plugins: ['@babel/plugin-transform-modules-commonjs']
37-
// }
38-
// },
3927
{
4028
test: /\.js$/,
4129
enforce: 'pre',
@@ -46,9 +34,6 @@ module.exports = {
4634
optimization: {
4735
minimize: true,
4836
},
49-
// plugins: [
50-
// new BundleAnalyzerPlugin()
51-
// ],
5237
output: {
5338
path: path.resolve('dist'),
5439
filename: `${filename}.es5.js`,
@@ -57,6 +42,7 @@ module.exports = {
5742
plugins: [
5843
new CleanWebpackPlugin(),
5944
new NormalModuleReplacementPlugin(/.js$/, (resource) => {
45+
if (/node_modules/.test(resource.context)) return
6046
resource.request = resource.request.replace(/.js$/, '')
6147
})
6248
],

0 commit comments

Comments
 (0)