Reputation: 1059
I've worked with Angular CLI Builder by creating a custom builder which extend asset config in angular.json
in case library has it's own asset. I used nrwl
for managing workspace.
I create a angular cli builder library and run npm link
. It creates a dist folder. In the project that uses the library, I run npm link packagename
but when I run npm run build
, it says Can not find module X in path ../src/command
. I don't understand why it looks at src
folder instead of dist
folder?
My package.json file
{
"name": "packagename",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"builders": "builders.json",
"scripts": {
"build": "tsc"
},
"devDependencies": {
"@angular-devkit/architect": "^0.803.3",
"prettier": "1.18.2",
"ts-jest": "24.0.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "^3.4.5"
}
}
And tsconfig.json file
{
"compilerOptions": {
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"resolveJsonModule": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"outDir": "dist",
"rootDir": "src",
"module": "commonjs",
"target": "es5",
"types": ["node"],
"lib": ["es2015", "es2017"]
},
"include": ["src/**/*.ts"],
"exclude": ["example/**/*.ts"]
}
Could you help me with this?
Upvotes: 2
Views: 3257
Reputation: 1059
Everything works as expected. When I have a package, I need to point angular.json to use my builder. The problem is when it looks at builders.json
{
"builders": {
"browser": {
"implementation": "./dist/browser", --it was "./src/browser"
"schema": "../../../node_modules/@angular-devkit/build-angular/src/browser/schema.json",
"description": "Add assets and runs @angular-devkit/build-angular:browser"
}
}
}
That's why it points to src
folder instead of dist
folder.
Upvotes: 1