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.

Module resolution setting not respected

See original GitHub issue

Type of Issue

[x] Bug Report
[ ] Feature Request

Description

I have a tsconfig.json with the custom configuration of paths. Each path alias has two entries, with a dist and a projects folder(for debugging purposes). After the update to ng-packagr@4.6.0 my library build is failing with the following error pattern:

TS6059: File 'absolute-path/projects/my-project/src/lib/my-project.module.ts' is not under 'rootDir' 'absolute-path/projects/my-other-project/src'. 'rootDir' is expected to contain all source files.

I figured that the commit causing this is 3f56df2, which forces us into Classic TypeScript module resolution, which quite frankly makes no sense.

From TypeScript documentation:

This used to be TypeScript’s default resolution strategy. Nowadays, this strategy is mainly present for backward compatibility.

Question: If that was done to assure some sort of backward compatibility, should people that require it do it themselves?


How To Reproduce

Checkout: https://github.com/klemenoslaj/ng-packagr-module-resolution-bug Execute: ng build library && ng build library2

Expected Behaviour

  • Developers should be able to customize their TypeScript paths the way it makes sense for them
  • The configuration developer maintains should actually be the one configuring TypeScript

Version Information

Angular CLI: 7.2.4
Node: 10.15.0
OS: darwin x64
Angular: 7.2.4
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.12.4
@angular-devkit/build-angular      0.12.4
@angular-devkit/build-ng-packagr   0.12.4
@angular-devkit/build-optimizer    0.12.4
@angular-devkit/build-webpack      0.12.4
@angular-devkit/core               7.2.4
@angular-devkit/schematics         7.2.4
@ngtools/json-schema               1.1.0
@ngtools/webpack                   7.2.4
@schematics/angular                7.2.4
@schematics/update                 0.12.4
ng-packagr                         4.7.0
rxjs                               6.3.3
typescript                         3.2.4
webpack                            4.28.4

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
alan-agius4commented, Feb 9, 2019

Because only relative files are resolved, hence node_modules will not be part of the compilation, which causes a thinner program to the created, and less files loaded in memory.

I’ll try to look into this, in the coming days.

0reactions
github-actions[bot]commented, Jun 19, 2020

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

"module": "node12" becomes invalid with "moduleResolution ...
If "moduleResolution" contradicts "module": "node12" there may be a warning or an error - or it could be simply ignored.
Read more >
Setting up absolute module resolution in Typescript and Node
I think what you're really looking for is relative paths, not absolute. Have you tried using. import logger from './logger';.
Read more >
Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >
JavaScript modules - MDN Web Docs
Most servers already set the correct type for .js files, but not yet ... module file, followed by a comma-separated list of the...
Read more >
API - esbuild
Advanced options: ... By default esbuild will not bundle the input files. ... Entry points with exports in CommonJS module syntax will be...
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