fix: resolve webpack and TypeScript declaration file conflicts

This commit is contained in:
Abhinav Kumar
2025-07-05 19:30:34 +05:30
parent 00840e12d3
commit 2630d42102
4 changed files with 36 additions and 9 deletions

View File

@@ -13,7 +13,7 @@
"scripts": {
"start": "webpack serve --config ./webpack/dev.config.js",
"dev": "nodemon --watch ./src/ -e ts,tsx --exec npm run build",
"build": "webpack --config ./webpack/prod.config.js && tsc --declaration --emitDeclarationOnly && tsc-alias",
"build": "webpack --config ./webpack/prod.config.js && tsc --project tsconfig.declaration.json && tsc-alias",
"test": "jest",
"lint": "tsc --noEmit && eslint ./src/**/* --ext .ts,.tsx",
"lint:fix": "eslint --fix ./src/**/* --ext .ts,.tsx",
@@ -63,7 +63,7 @@
"typescript": "^5.1.6",
"webpack": "^5.76.2",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.15.1"
"webpack-dev-server": "^5.2.2"
},
"dependencies": {
"@emotion/react": "^11.10.6",
@@ -80,10 +80,10 @@
"paper": "^0.12.17",
"pathfinding": "^0.4.18",
"react-hook-form": "^7.43.2",
"react-quill": "^2.0.0",
"react-quill": "^0.0.2",
"react-router-dom": "^6.8.1",
"uuid": "^9.0.0",
"zod": "3.22.2",
"zod": "^3.25.74",
"zustand": "^4.3.3"
},
"peerDependencies": {

16
tsconfig.declaration.json Normal file
View File

@@ -0,0 +1,16 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": false,
"noEmit": false,
"outDir": "./dist"
},
"exclude": ["node_modules", "./dist", "./docs", "**/*.test.ts", "**/*.test.tsx"],
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/global.d.ts"
]
}

View File

@@ -10,7 +10,8 @@
"jsx": "react-jsx",
"allowJs": true,
"allowSyntheticDefaultImports": true,
"declaration": true,
"declaration": false,
"declarationMap": false,
"strict": true,
"module": "es6",
"moduleResolution": "node",
@@ -22,5 +23,5 @@
"**/*.ts",
"**/*.tsx",
"src/global.d.ts"
],
]
}

View File

@@ -7,12 +7,13 @@ module.exports = {
target: 'web',
entry: {
'index': './src/index.ts',
'/standaloneExports': './src/standaloneExports.ts',
'standaloneExports': './src/standaloneExports.ts',
},
output: {
path: path.resolve(__dirname, '../dist'),
filename: '[name].js',
libraryTarget: 'commonjs2'
libraryTarget: 'commonjs2',
clean: true
},
externals: {
react: {
@@ -36,7 +37,16 @@ module.exports = {
rules: [
{
test: /\.(ts|tsx)$/,
use: 'ts-loader',
use: {
loader: 'ts-loader',
options: {
transpileOnly: true,
compilerOptions: {
declaration: false,
emitDeclarationOnly: false
}
}
},
exclude: /node_modules/
},
{