-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use exported models #992
Comments
How are you exporting? from your example all you are doing is importing. If you wanrt export you should replace the |
Model class: src/app/modules/my-custom-module/models/my-model.ts
Index file: src/app/modules/my-custom-module/models/index.ts
Export file at root: models.ts ng-packagr file at root: public_api.ts
Main project code:
I believe, I'm missing something about mapping Error:
|
You need to export the models from models/index in your public_api
…On Thu, 05 Jul 2018 at 14:45, sataqi ***@***.***> wrote:
@alan-agius4 <https://github.com/alan-agius4>
Model class: *src/app/modules/my-custom-module/models/my-model.ts*
export class MyModel {
constructor() {
// default values for props here
}
// ...props here
}
Index file: *src/app/modules/my-custom-module/models/index.ts*
export * from './my-model';
export * from './my-other-model';
Export file at root: *models.ts*
export * from './src/app/modules/my-custom-module/models/index';
ng-packagr file at root: *public_api.ts*
export * from './models';
export * from './src/app/modules/my-custom-module/my-custom-module.module';
export * from './src/app/modules/my-custom-module/components/index';
Main project code:
import {MyCustomModule} from 'my-custom-library'; // works
import {MyModel} from 'my-custom-library'; // works
import {MyModel} from 'my-custom-library/models'; // does not work
I believe, I'm missing something about mapping webpack module resolution
because VS Code recognizes the import, intellisense works and even Ctrl +
Click navigates to right file but webpack fails in compilation.
*Error:*
module not found error can't resolve my-custom-library/models
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#992 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQv-Wp-Os9mNh7-2P85DVPS8vWcUFAIyks5uDgpUgaJpZM4VDgTw>
.
|
Ok but wouldn't my
but I want my models
|
If you wish to use With your current implementation that is something which is not possible. Take a look at this documentation; https://github.com/dherges/ng-packagr/blob/master/docs/secondary-entrypoints.md |
I'll try that and update. thank you! |
Tried you suggestion but getting this error. |
Can you create a small reproduction please? |
nvm. It worked using |
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem. |
Type of Issue
[ ] Bug Report
[ ] Feature Request
[x] Question
Description
How to create sub package for each kind of export? For example, I want
import
statement to look like this for each type of file exported:Models (inluding interfaces and classes)
import {FooModel, BarModel} from 'my-lib/models'
;Enums
import {FooTypes, BarTypes} from 'my-lib/enums'
;Right now, as all the exports are from
public_api.ts
file, myimport
statements look like this:Models (inluding interfaces and classes)
import {FooModel, BarModel} from 'my-lib'
;Enums
import {FooTypes, BarTypes} from 'my-lib'
;I tried creating export files but
webpack
fails to compile. Here's the link to full question, with code and error statement: StackOverflowThe text was updated successfully, but these errors were encountered: