Skip to content

Commit

Permalink
fix: build working dist
Browse files Browse the repository at this point in the history
TypeStrong/ts-loader#1463

`transpileOnly: true` doesn't work
`tsconfig.cjs.json` doesn't work
Use `NormalModuleReplacementPlugin` as workaround
  • Loading branch information
unional committed Jun 2, 2022
1 parent ee93606 commit 2087346
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 1,377 deletions.
2 changes: 2 additions & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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-*
3 changes: 0 additions & 3 deletions babel.config.mjs

This file was deleted.

4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
20 changes: 3 additions & 17 deletions webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -46,9 +34,6 @@ module.exports = {
optimization: {
minimize: true,
},
// plugins: [
// new BundleAnalyzerPlugin()
// ],
output: {
path: path.resolve('dist'),
filename: `${filename}.es5.js`,
Expand All @@ -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$/, '')
})
],
Expand Down
Loading

0 comments on commit 2087346

Please sign in to comment.