fix: resolves paths after typese are compiled

This commit is contained in:
Mark Mankarious
2023-08-08 16:35:06 +01:00
parent 4a4f168671
commit b2416f3e98
6 changed files with 142 additions and 56 deletions

View File

@@ -29,5 +29,9 @@
"react/require-default-props": [0],
"no-param-reassign": ["error", { "props": true, "ignorePropertyModificationsFor": ["draftState"] }],
"arrow-body-style": ["error", "always"]
}
},
"ignorePatterns": [
"/dist",
"/node_modules"
]
}

81
package-lock.json generated
View File

@@ -62,6 +62,7 @@
"svg-url-loader": "^8.0.0",
"ts-jest": "^29.0.5",
"ts-loader": "^9.4.2",
"tsc-alias": "^1.8.7",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"typescript": "^5.1.6",
"webpack": "^5.76.2",
@@ -10906,6 +10907,19 @@
"multicast-dns": "cli.js"
}
},
"node_modules/mylas": {
"version": "2.1.13",
"resolved": "https://registry.npmjs.org/mylas/-/mylas-2.1.13.tgz",
"integrity": "sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg==",
"dev": true,
"engines": {
"node": ">=12.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/raouldeheer"
}
},
"node_modules/nanoid": {
"version": "3.3.6",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
@@ -11501,6 +11515,15 @@
"node": ">=8"
}
},
"node_modules/plimit-lit": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/plimit-lit/-/plimit-lit-1.5.0.tgz",
"integrity": "sha512-Eb/MqCb1Iv/ok4m1FqIXqvUKPISufcjZ605hl3KM/n8GaX8zfhtgdLwZU3vKjuHGh2O9Rjog/bHTq8ofIShdng==",
"dev": true,
"dependencies": {
"queue-lit": "^1.5.0"
}
},
"node_modules/postcss": {
"version": "8.4.25",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.25.tgz",
@@ -11793,6 +11816,12 @@
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==",
"dev": true
},
"node_modules/queue-lit": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/queue-lit/-/queue-lit-1.5.0.tgz",
"integrity": "sha512-IslToJ4eiCEE9xwMzq3viOO5nH8sUWUCwoElrhNMozzr9IIt2qqvB4I+uHu/zJTQVqc9R5DFwok4ijNK1pU3fA==",
"dev": true
},
"node_modules/queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
@@ -13450,6 +13479,23 @@
"node": ">=8"
}
},
"node_modules/tsc-alias": {
"version": "1.8.7",
"resolved": "https://registry.npmjs.org/tsc-alias/-/tsc-alias-1.8.7.tgz",
"integrity": "sha512-59Q/zUQa3miTf99mLbSqaW0hi1jt4WoG8Uhe5hSZJHQpSoFW9eEwvW7jlKMHXWvT+zrzy3SN9PE/YBhQ+WVydA==",
"dev": true,
"dependencies": {
"chokidar": "^3.5.3",
"commander": "^9.0.0",
"globby": "^11.0.4",
"mylas": "^2.1.9",
"normalize-path": "^3.0.0",
"plimit-lit": "^1.2.6"
},
"bin": {
"tsc-alias": "dist/bin/index.js"
}
},
"node_modules/tsconfig-paths": {
"version": "3.14.2",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz",
@@ -22697,6 +22743,12 @@
"thunky": "^1.0.2"
}
},
"mylas": {
"version": "2.1.13",
"resolved": "https://registry.npmjs.org/mylas/-/mylas-2.1.13.tgz",
"integrity": "sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg==",
"dev": true
},
"nanoid": {
"version": "3.3.6",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
@@ -23134,6 +23186,15 @@
"find-up": "^4.0.0"
}
},
"plimit-lit": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/plimit-lit/-/plimit-lit-1.5.0.tgz",
"integrity": "sha512-Eb/MqCb1Iv/ok4m1FqIXqvUKPISufcjZ605hl3KM/n8GaX8zfhtgdLwZU3vKjuHGh2O9Rjog/bHTq8ofIShdng==",
"dev": true,
"requires": {
"queue-lit": "^1.5.0"
}
},
"postcss": {
"version": "8.4.25",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.25.tgz",
@@ -23337,6 +23398,12 @@
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==",
"dev": true
},
"queue-lit": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/queue-lit/-/queue-lit-1.5.0.tgz",
"integrity": "sha512-IslToJ4eiCEE9xwMzq3viOO5nH8sUWUCwoElrhNMozzr9IIt2qqvB4I+uHu/zJTQVqc9R5DFwok4ijNK1pU3fA==",
"dev": true
},
"queue-microtask": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
@@ -24565,6 +24632,20 @@
}
}
},
"tsc-alias": {
"version": "1.8.7",
"resolved": "https://registry.npmjs.org/tsc-alias/-/tsc-alias-1.8.7.tgz",
"integrity": "sha512-59Q/zUQa3miTf99mLbSqaW0hi1jt4WoG8Uhe5hSZJHQpSoFW9eEwvW7jlKMHXWvT+zrzy3SN9PE/YBhQ+WVydA==",
"dev": true,
"requires": {
"chokidar": "^3.5.3",
"commander": "^9.0.0",
"globby": "^11.0.4",
"mylas": "^2.1.9",
"normalize-path": "^3.0.0",
"plimit-lit": "^1.2.6"
}
},
"tsconfig-paths": {
"version": "3.14.2",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz",

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",
"build": "webpack --config ./webpack/prod.config.js && tsc --declaration --emitDeclarationOnly && tsc-alias",
"test": "jest",
"lint": "eslint ./src/**/*.{ts,tsx}",
"lint:fix": "eslint --fix ./src/**/*.{ts,tsx}"
@@ -54,6 +54,7 @@
"svg-url-loader": "^8.0.0",
"ts-jest": "^29.0.5",
"ts-loader": "^9.4.2",
"tsc-alias": "^1.8.7",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"typescript": "^5.1.6",
"webpack": "^5.76.2",

View File

@@ -1,23 +1,23 @@
{
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"src/*": [
"./src/*"
],
"src/*": ["./*"],
},
"outDir": "./dist",
"noImplicitAny": true,
"module": "es6",
"target": "es5",
"target": "es6",
"jsx": "react",
"allowJs": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"declaration": true,
"strict": true,
"module": "es6",
"moduleResolution": "node",
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"**/*.ts",
"**/*.tsx",
"src/global.d.ts"
],
}

View File

@@ -1,53 +1,53 @@
const path = require("path");
const HtmlWebPackPlugin = require("html-webpack-plugin");
const path = require('path');
const HtmlWebPackPlugin = require('html-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
module.exports = {
mode: "development",
entry: "./src/index.tsx",
devtool: "eval-cheap-source-map",
mode: 'development',
entry: './src/index.tsx',
devtool: 'eval-cheap-source-map',
output: {
filename: "main.js",
path: path.resolve(__dirname, "build"),
filename: 'main.js',
path: path.resolve(__dirname, 'build')
},
devServer: {
static: {
directory: path.join(__dirname, "build"),
directory: path.join(__dirname, 'build')
},
allowedHosts: [
'.csb.app', // So Codesandbox.io can run the dev server
'.ngrok-free.app'
],
port: 3000,
port: 3000
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
use: "ts-loader",
exclude: /node_modules/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
use: ['style-loader', 'css-loader']
},
{
test: /\.svg$/,
use: [
{
loader: 'svg-url-loader'
},
],
},
],
}
]
}
]
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
plugins: [new TsconfigPathsPlugin()],
extensions: ['.tsx', '.ts', '.js'],
plugins: [new TsconfigPathsPlugin()]
},
plugins: [
new HtmlWebPackPlugin({
template: path.resolve(__dirname, "../src/index.html"),
}),
],
template: path.resolve(__dirname, '../src/index.html')
})
]
};

View File

@@ -1,51 +1,51 @@
const path = require("path");
const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
module.exports = {
mode: "production",
entry: "./src/Isoflow.tsx",
mode: 'production',
entry: './src/Isoflow.tsx',
output: {
path: path.resolve(__dirname, "../dist"),
filename: "index.js",
libraryTarget: "commonjs2",
path: path.resolve(__dirname, '../dist'),
filename: 'index.js',
libraryTarget: 'commonjs2'
},
externals: {
react: {
commonjs: "react",
commonjs2: "react",
amd: "React",
root: "React",
},
"react-dom": {
commonjs: "react-dom",
commonjs2: "react-dom",
amd: "ReactDOM",
root: "ReactDOM",
commonjs: 'react',
commonjs2: 'react',
amd: 'React',
root: 'React'
},
'react-dom': {
commonjs: 'react-dom',
commonjs2: 'react-dom',
amd: 'ReactDOM',
root: 'ReactDOM'
}
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
use: "ts-loader",
exclude: /node_modules/,
use: 'ts-loader',
exclude: /node_modules/
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
use: ['style-loader', 'css-loader']
},
{
test: /\.svg$/,
use: [
{
loader: 'svg-url-loader'
},
],
},
],
}
]
}
]
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
extensions: ['.tsx', '.ts', '.js'],
plugins: [new TsconfigPathsPlugin()]
},
}
};