Skip to content

Watching changes in the library throws an error when the application is served (Consuming your library during development). #136

Closed
@raphael-volt

Description

@raphael-volt

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions