Here is what I want to achieve.
I want to make a package that I will use to share typescript interface, or common config that will be shared between my front-end (react) and my back-end (nestjs)
I have created project called "shared" and made a link in my package.json.
Like so : "shared": "file:../shared",
It works great my React, where can use my interface or anything from "shared" without any error !
I did the same in my nestjs project, there is not error in the editor and I can see the shared package in the node_modules. But when I compile the project, it fails with :
Error: Cannot find module 'shared/interfaces/user'
So I guess the problem comes from something in my nestjs conf or webpack... But I don't know what.
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"moduleResolution": "node",
},
}
webpack-hmr.config.js
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
const { RunScriptWebpackPlugin } = require('run-script-webpack-plugin');
module.exports = function (options) {
return {
...options,
entry: ['webpack/hot/poll?500', options.entry],
watch: true,
externals: [
nodeExternals({
allowlist: ['webpack/hot/poll?500'],
}),
],
plugins: [
...options.plugins,
new webpack.HotModuleReplacementPlugin(),
new RunScriptWebpackPlugin({ name: options.output.filename }),
new webpack.WatchIgnorePlugin( {paths: [/\.js$/, /\.d\.ts$/] }),
],
};
};
If you have any idea :) Thanks guys !
--display-error-detailsargument and post the results? This has helped me in the past and you'd be surprised to see that sometimes the root cause is actually an entirely unrelated issue.