I started using NPM workspace in my project to avoid "../../../" imports.
In my project after the compilation (TypeScript) I need to use browerify to create a bundle for the web.
The problem is that with NPM workspace this does not work anymore
Browerify does not found "@koala-engine/core/../*.js" in the compiled JS, in order to compile I probably need some tool to convert the package path to a relative path.
(I'm not using any UI frameworks or bundler)
Directories:
- koala-engine
|- packages
|- core
|- demo
|- editor
package.json
tsconfig.json
package.json
{
"name": "koala-engine",
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
"browserify-build": "browserify public/scripts/demo/index.js -o public/bundle.js",
"server": "npm-run-all browserify-build start",
"dev": "tsc-watch --onsuccess \"npm run server\"",
"build": "tsc",
"start": "node server/index.js"
},
"workspaces": [
"packages/core",
"packages/editor",
"packages/demo"
],
"keywords": [],
"author": "Lorenzo774",
"license": "MIT",
"dependencies": {
"tsc-watch": "^5.0.3",
"typescript": "^4.7.4",
"browserify": "^17.0.0",
"npm-run-all": "^4.1.5"
}
}
tsconfig.json
{
"compilerOptions": {
"rootDir": "packages",
"outDir": "public/scripts",
"lib": ["Es2016", "dom"],
"module": "CommonJS",
"target": "ES6",
"moduleResolution": "Node",
"removeComments": true
}
}