Secondary entry point bug: `src/` path gets part of package import path
See original GitHub issueType of Issue
[x] Bug Report
[ ] Feature Request
Description
When placing the main entry point in src/
and every subentry point in a new folder inside src/
you will get the primary point correctly at @my/package-name
but every secondary entry point is only accessible by the path @my/package-name/src/*
.
This is a remaining error after fixing the base url stuff in this PR https://github.com/dherges/ng-packagr/pull/862
Relates to: https://github.com/dherges/ng-packagr/issues/854
How To Reproduce
I created a new example in the ng-packagr project. See my branch https://github.com/georgiee/ng-packagr/tree/src-entry-point-bug.
- Launch example
nested-src
. - It works. But only because it’s fixed by providing this import
import { STATIC_FOO_VALUE, FooClass } from '@sample/nested-src/src/foo';
instead of
import { STATIC_FOO_VALUE, FooClass } from '@sample/nested-src/foo';
Expected Behaviour
This path should work:
import { STATIC_FOO_VALUE, FooClass } from '@sample/nested-src/foo';
Version Information
$: ng -v
@angular-devkit/architect 0.6.3 (cli-only)
@angular-devkit/core 0.6.0
@angular-devkit/schematics 0.6.3 (cli-only)
@angular/cdk 6.0.1
@angular/router 6.0.1
@ngtools/json-schema 1.1.0
@schematics/angular 0.6.3 (cli-only)
@schematics/update 0.6.3 (cli-only)
rxjs 6.1.0
typescript 2.7.2
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:30 (14 by maintainers)
Top Results From Across the Web
Service is not under 'rootDir' in Angular secondary entry point
I understand that the compilation of secondary entry points is separate and "treated as a separate project", hence the error.
Read more >importlib — The implementation of import — Python 3.11.1 ...
The path argument should be the “path” to where the source code originated from, which can be an abstract concept (e.g. location in...
Read more >How to improve your Angular library | Developapa
You can NOT use relative imports between difference entry points. You need to import from the build package like you would from a...
Read more >Building an Angular Library with multiple entry points | Articles
A npm package can have additional entry points, called secondary entry ... It specifies the path of the build output and the entry...
Read more >Documentation - Module Resolution - TypeScript
Use non-relative paths when importing any of your external dependencies. ... In our example, if Node.js found the file /root/src/moduleB/package.json ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there any intention on clarifying why placing package.json under the src folder works here? First, it is very commonplace and standard for the package.json to be at the root level of the package it is describing. Second, it’s not intuitive that
produces the packages:
while
produces the packages:
Issues with pathing and dependencies notwithstanding, the location of my source code does not change. Why does the location of the package.json file itself dictate package destinations?
My exact use case doesn’t need a main module so I would rather have a package.json at the root that has a name of the common namespace (abc/def, in my example) and is completely independent from the packaged code itself and ng/package.json files in each of the feature modules that dictate how they would be packaged.
This also effects when adding secondary entry point to lib generated from
ng g library