question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not use [pre/post]install script for build angular package during local installation of traditional node package (via npm link)

See original GitHub issue

Type of Issue

[X] Bug Report
[ ] Feature Request

Description

I try to use yarn workspaces for my angular project with angular modules included in separate packages for save disk space and for building speed. And I can’t use ng_packagr, because it simply ignores all files with paths which containing ‘node_modules’ string. But you can’t do this when you use a local installation and want to use install script for build angular packages, because the install script runs for the localy installed node package inside node_modules folder.

For example structure of my project:

root_of_project
\--node_modules
|   \--my_package_1 (auto symlink to ../libs/my_package_1)
|   \--my_package_2 (auto symlink to ../libs/my_package_2)
|   \--my_package_XX (auto symlink to ../libs/my_package_XX)
|   \--other_node_modules_for_main_app_and_all_my_packages
\--libs
|   \--my_package_1
|   |   \--app
|   |   |   \-- some_kind_of_demo_usage
|   |   \--lib
|   |   |   \--src
|   |   |   |   \--my_module.ts
|   |   |   \--public_api.ts
|   |   |   \--package.json
|   |   \--package.json
|   |       \--scripts
|   |           \--install: ng-packagr -p lib/package.json
|   \--my_package_2
|   \--my_package_XX
\--src
|   \--some_kind_of_main_angular_application
\--tsconfig-flat.json
|   \--compilerOptions:baseUrl: my_package_1 -> my_package_1/lib/
|   \--compilerOptions:baseUrl: my_package_XX -> my_package_XX/lib/
\--tsconfig-use-packages.json
|   \--compilerOptions:baseUrl: my_package_1 -> my_package_1/dist/package
|   \--compilerOptions:baseUrl: my_package_XX -> my_package_XX/dist/package
\--package.json
    \--workspaces
        \--libs/*

When I run yarn command inside root folder of my project:

  1. yarn install all dependences for main application and for all my node packages in root node_modules directory.
  2. yarn create symlinks from all my node packages to root node_modules directory (as npm link).
  3. yarn run install scripts in all my installed node packages (inside node_modules directory). and this last point not work for my packages with angular modules because in this file https://github.com/dherges/ng-packagr/blob/master/src/lib/ts/analyse-dependencies-transformer.ts ng-packagr exclude all files, containing ‘/node_modules/’ string in their paths.

How To Reproduce

It can be reproduced if you make local install via npm link any node package and if you try to build your angular package with ng-packagr via [post/pre]install script. Because both npm and yarn for local installation jist create symlinks and then try to run install script inside.

I think it is important bug for utility which tries to implement the creation of packages.

Expected Behaviour

ng_packagr should not simply drop all paths containing nodel_modules string, but analyze whether this path leads to the current package folder installed in the module_module.

Version Information

$ node_modules/.bin/ng-packagr --version
ng-packagr:            2.4.2
@angular/compiler:     5.2.9
@angular/compiler-cli: 5.2.9
rollup:                0.55.5
tsickle:               0.27.5
typescript:            2.6.2
$ yarn -v
1.5.1
$ npm -v
5.6.0
$ ver
Microsoft Windows [Version 6.1.7601]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jimbasiliocommented, Jun 25, 2018

I believe I also have this issue. We pull in source code for our library into node_modules and then run the cli build there. It appears the result is it can’t find .ts files to roll into the FESM2015 bundle.

Is there any workaround for this? I notice the link to the transformer no longer works which tells me the code has since been refactored? https://github.com/dherges/ng-packagr/blob/master/src/lib/ts/analyse-dependencies-transformer.ts

0reactions
github-actions[bot]commented, Aug 10, 2021

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Installing a local module using npm? - Stack Overflow
you just provide one <folder> argument to npm install , argument should point toward the local folder instead of the package name:
Read more >
scripts - npm Docs
Runs BEFORE the package is packed, i.e. during npm publish and npm pack · Runs on local npm install without any arguments ·...
Read more >
[Pro Tip] `npm link` explained - DEV Community ‍ ‍
npm link creates a symbolic link (symlink) from your <global node_modules> directory to the local library's directory. · The catch is that you ......
Read more >
@lerna/bootstrap | Yarn - Package Manager
Link local packages together and install remaining package dependencies ... core: more detailed error message when version cannot be found (#3424 (b729b0c) ...
Read more >
Converting your Angular CLI application into a NPM Module
One downside to this method is that you must re-install using this command after each build of your local package. Every. Time. Clearly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found