Closed
Description
Context :
- Consuming the library in development mode
npm link
- Changes in the dist directory of the library are watched
npm run build:watch
- An application that consumes the library is served
ng serve
Make some changes in a file of the src directory of the library.
As the clean:dist task deletes all files in the dist directory, the index.js file is missing,so webpack can't load it to compile :
ERROR in .-lib/dist/index.js
Module build failed: Error: ENOENT: no such file or directory, open 'LIBRARY-DIRECTORY/dist/index.js'
@ ./src/app/app.module.ts 10:0-44
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
webpack: Failed to compile.
Fast fix : editing the library gulpfile:
/**
* 1. Delete /dist folder
*/
gulp.task('clean:dist', function () {
// Delete contents but not dist folder to avoid broken npm links
// when dist directory is removed while npm link references it.
return deleteFolders([distFolder + '/**', '!' + distFolder, '!' + distFolder + "/index.js"]);
});
Watch changes an serve the application again.
Make another changes in a file of the src directory of the library.
webpack will successfully compile.