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.

Secondary Entry Points fail resolve path

See original GitHub issue

Type of Issue

[x] Bug Report
[ ] Feature Request

Description

I build secondary entry point for holding ngrx reducers/action/services, ng-packagr fail to build the relative path to entity in main library.

  • Main library path motortrack-lib
  • Secondary path motortrack-lib/services
export declare const selectTripEntity: import("@ngrx/store").MemoizedSelector<object, import("../../../../../../../dist/motortrack-lib/public_api").TripContract>;

the error is ng-packagr add an extra ‘…/’ on path

How To Reproduce

For reproduce just follow this entity adapter tutorial and implement it in secondary entry point lib.

In reducers i export entity as follow

// trips.reducer.ts
import {TripContract} form '@motortrack-lib'
// state

export interface State {
  selectedTrip: TripContract;
}

export const getSelectedTrip = (state: State) => state.selectedTrip;

then in index file i create a selector by importing that constant

index.ts
import * as fromTrip from './trips.reducer';

export const selectTripState= createFeatureSelector<fromTrip.State>('trips');

export const selectTripEntity = createSelector(
  selectTripState,
  fromTrip.getSelectedTrip
);

On the other hand if i put all in one file i don’t have any error because it use the imported contract from the top of the file

//trips.reducer.d.ts
export const selectTripEntity = import("@ngrx/store").MemoizedSelector<object,TripContract>;

Expected Behaviour

the extra ‘…/’ should not be added

Version Information

ng-packagr:            4.7.0
@angular/compiler:     7.2.2
rollup:                0.67.4
tsickle:               0.34.0
typescript:            3.2.4
@ngrx                  7.1.0

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:15
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
evenicoulddoitcommented, Apr 16, 2019

I’m getting the same error as those reporting here, again with NgRx selectors, however if I’m reading the situation correctly this issue isn’t limited to secondary endpoints.

My build is failing on a secondary endpoint (mypackage/testing), but the error reported makes it clear that the issue is really with the definition file itself.

Simplified situation:

  • @x/core package
  • @x/sub package - has a dependency on @x/core
  • @x/sub/selectors.d.ts produces relative and incorrect imports. They’re one level too deep (e.g. ../../../../dist/core/lib/xyz)

So, it appears that the definition files are the problem. As @rams23 has commented, updating all of the selector typings to explicitly declare their types is one solution, but both super ugly to do in mass, and also more difficult when using a feature adapter’s getSelectors() method.

Unfortunately I lack the specific package knowledge to tell if the issue lies:

  • In NgRx’s selector definitions (given that all the issues to date have cited them)
  • An issue with ng-packagr
  • An issue with one of the multitude other libraries involve in a ng build call
1reaction
rams23commented, Apr 9, 2019

If I explicitly import the type and I use in the selector ‘as’ like this:

import {RequestStatus} from '@mylib/core'

export const getDeleteLocationState = createSelector(
  selectProfile,
  state => state.locations.requestStatus as RequestStatus
);

it works fine but it is another workaround

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating Secondary Entry Points for your Angular Library
In this article, we will take a look at how we can utilise ng-packagr secondary entry points to split our Angular Library even...
Read more >
Angular 9 library with subentry points circular dependency
You can have references between the secondary entry points again only in one direction. During build the references are resolved and the build ......
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 >
Pitfalls with Module Federation and Angular
"No required version specified" and Secondary Entry Points ... Unable to find required version for "@angular/common" in description file ...
Read more >
Building an Angular Library with multiple entry points | Articles
The CLI will use the source root path (configured in angular.json) and will append lib/ to the path. This lib prefix is hard-coded...
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