From 7ec5fa4f5ae64894772eb4d52ec4d31df1ba452f Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Wed, 1 Jun 2022 23:08:24 -0700 Subject: [PATCH] fix: build working dist https://github.com/TypeStrong/ts-loader/issues/1463 `transpileOnly: true` doesn't work `tsconfig.cjs.json` doesn't work Use `NormalModuleReplacementPlugin` as workaround --- .depcheckrc.yml | 2 ++ babel.config.mjs | 3 --- package.json | 4 ---- webpack.config.cjs | 20 +++----------------- 4 files changed, 5 insertions(+), 24 deletions(-) delete mode 100644 babel.config.mjs diff --git a/.depcheckrc.yml b/.depcheckrc.yml index 3cb350a..05258d3 100644 --- a/.depcheckrc.yml +++ b/.depcheckrc.yml @@ -4,10 +4,12 @@ ignores: - '@swc/*' - '@size-limit/*' - '@types/*' + - clean-webpack-plugin - jest-* - param-case - pascal-case - semantic-release + - source-map-loader - ts-jest - ts-loader - webpack-* diff --git a/babel.config.mjs b/babel.config.mjs deleted file mode 100644 index f8e3f51..0000000 --- a/babel.config.mjs +++ /dev/null @@ -1,3 +0,0 @@ -export default { - plugins: ['@babel/plugin-transform-modules-commonjs'] -} diff --git a/package.json b/package.json index 64723f5..519f38a 100644 --- a/package.json +++ b/package.json @@ -74,9 +74,6 @@ "unpartial": "^0.7.3" }, "devDependencies": { - "@babel/plugin-transform-modules-commonjs": "^7.18.2", - "@babel/preset-env": "^7.18.2", - "@babel/preset-typescript": "^7.17.12", "@commitlint/cli": "^17.0.0", "@commitlint/config-conventional": "^17.0.0", "@semantic-release/changelog": "^6.0.1", @@ -89,7 +86,6 @@ "@types/jest": "^27.5.1", "@typescript-eslint/eslint-plugin": "^5.20.0", "@typescript-eslint/parser": "^5.23.0", - "babel-loader": "^8.2.5", "clean-webpack-plugin": "^4.0.0", "depcheck": "^1.4.3", "eslint": "8.16.0", diff --git a/webpack.config.cjs b/webpack.config.cjs index 64fa43f..e57ffe5 100644 --- a/webpack.config.cjs +++ b/webpack.config.cjs @@ -20,22 +20,10 @@ module.exports = { loader: 'ts-loader', test: /\.ts$/, options: { - configFile: 'tsconfig.cjs.json', - transpileOnly: true + configFile: 'tsconfig.esm.json', + // transpileOnly: true } }, - // { - // loader: 'babel-loader', - // test: /\.js$/, - // options: - // { - // presets: [ - // '@babel/preset-env', - // '@babel/preset-typescript' - // ], - // plugins: ['@babel/plugin-transform-modules-commonjs'] - // } - // }, { test: /\.js$/, enforce: 'pre', @@ -46,9 +34,6 @@ module.exports = { optimization: { minimize: true, }, - // plugins: [ - // new BundleAnalyzerPlugin() - // ], output: { path: path.resolve('dist'), filename: `${filename}.es5.js`, @@ -57,6 +42,7 @@ module.exports = { plugins: [ new CleanWebpackPlugin(), new NormalModuleReplacementPlugin(/.js$/, (resource) => { + if (/node_modules/.test(resource.context)) return resource.request = resource.request.replace(/.js$/, '') }) ],