Skip to content
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

Library with secondary entry points only #1655

Open
klemenoslaj opened this issue Jun 2, 2020 · 12 comments
Open

Library with secondary entry points only #1655

klemenoslaj opened this issue Jun 2, 2020 · 12 comments

Comments

@klemenoslaj
Copy link
Contributor

Type of Issue

[ ] Bug Report
[x] Feature Request

Description

Would it be good idea for ng-packagr to support a library consisting of secondary points alone?
Something like @angular/material is doing.

How To Reproduce

n/a

Expected Behaviour

@angular/material is a library that inspires a lot of other libraries, I am sure. Would it not be a good idea to support their structure?

Example:

| - library
  | - component-a
  | - component-b

Could result in @org/library/component-a and @org/library/component-b.

Version Information

n/a

@paulayo93
Copy link

Currently challenged by this issue. Is it possible to have the feature included?

@paulayo93
Copy link

Please is there a temporary workaround for this type of issue (as described by @klemenoslaj ) using ng-packagr?

Thanks for the help!

@JoostK
Copy link
Member

JoostK commented Jul 11, 2020

What's the problem here, exactly? @angular/material does have a primary entry-point, it's just empty. Would that not be a possibility with ng-packagr for some reason?

@klemenoslaj
Copy link
Contributor Author

Last time I tried having empty primary entry-point the build failed (worked after exporting some fake variable). I did not try it since, but can try again later today with latest version.

@JoostK
Copy link
Member

JoostK commented Jul 11, 2020

@klemenoslaj ah, I see. I can't think of any changes in this area, so I expect that to still behave the same. As you said, exporting a dummy could be a workaround.

@klemenoslaj
Copy link
Contributor Author

klemenoslaj commented Jul 11, 2020

@klemenoslaj ah, I see. I can't think of any changes in this area, so I expect that to still behave the same. As you said, exporting a dummy could be a workaround.

Yes, that's what I currently do. It is a bit awkward tho :)
I could contribute if empty endpoint is something you would want to support.

@SchnWalter
Copy link
Contributor

Just to add a note, we already have an undocumented support for empty "secondary entry points", which allows us to have a library that skips "one level" in the sub-package path:

@example/package
@example/package/core
@example/package/components/badge
@example/package/components/toggle
@example/package/components/toggle/testing
@example/package/components/testing/integration

Notice the missing @example/package/components and @example/package/components/testing sub-packages, see comments on: #1748 (comment)

This feature would be similar to that, if official support is added for such a feature, we should probably deal with these features in the same MR.

@leolio86400
Copy link

It is a fairly common issue from monorepo structures.

Ended on that few weeks ago, would it make sense to use this feature instead of having package.json everywhere?
https://nodejs.org/api/packages.html#packages_subpath_patterns

@SchnWalter
Copy link
Contributor

We can't use the subpath pattern because we have more data in our secondary entry point package.json files, and that pattern can't expose such data:

# cat package.json
{
  "main": "../bundles/myorg-mylib-subpackage.umd.js",
  "module": "../fesm2015/myorg-mylib-subpackage.js",
  "es2015": "../fesm2015/myorg-mylib-subpackage.js",
  "esm2015": "../esm2015/subpackage/myorg-mylib-subpackage.js",
  "fesm2015": "../fesm2015/myorg-mylib-subpackage.js",
  "typings": "myorg-mylib-subpackage.d.ts",
  "sideEffects": false,
  "name": "@myorg/mylib/subpackage"
}

@wojtek1150
Copy link

Just add ng-package.json and public-api.ts file into component-a folder. In root public-api file paste

export default void 0;

Should works as expected ;)

maxlongint added a commit to maxlongint/ngx-zorro that referenced this issue Jul 25, 2023
ng-packagr/ng-packagr#1655
辅助入口2大文件 index.ts ng-package.json
@johncrim
Copy link

I use this in the root public-api.ts:

// public-api.ts is required by ng-packagr and cannot be empty.
const DO_NOT_IMPORT = 'Do not import from @myorg/mylib; Submodules must be imported directly.';
export default DO_NOT_IMPORT;

But otherwise, same fix.

@tomavic
Copy link

tomavic commented Jan 5, 2024

Would you consider this as a best practice, using the public-api.ts file and re exporting all secondary entries instead of exporting fake string (which I always do xD )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

8 participants