yarn add --dev project-references-webpack-plugin
// webpack.config.ts
import { ProjectReferencesPlugin } from "project-references-webpack-plugin";
import type { Configuration } from "webpack";
const config: Configuration = {
resolve: {
extensions: [".ts", ".tsx", ".js"],
extensionAlias: {
".js": [".ts", ".tsx", ".js"],
".mjs": [".mts", ".mjs"],
".cjs": [".cts", ".cjs"],
},
plugins: [new ProjectReferencesPlugin()],
},
};
export default config;
import "library"; // => packages/library/src/index.ts
// packages/library/package.json
{
"name": "library",
"main": "./lib/index.js",
}
// packages/library/tsconfig.json
{
"compilerOptions": {
"rootDir": "./src",
"outDir": "./lib",
},
}
This project was inspired by webpack-project-references-alias.