-
Notifications
You must be signed in to change notification settings - Fork 12k
Webpack build breaks ability to use npm installed custom components #1624
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
Comments
@TheLarkInn this seems bad, probably related to the template loader. Can you add some insight? |
Is there a link or repo to this component we can test? |
I believe I know what's going on here but it will help to have this component as an example. |
@TheLarkInn @filipesilva The npm install command in the original message references this repo. https://github.com/NorthernLogic/angular-cli-imported-component-bug |
May need to apply the angular2-template-loader to both ts and js. |
I've been looking into this, and there isn't a easy solution to it right now. Basically, there's no decent way to bundle 3rd party libs that do not inline their html/css. At the moment we use some regex to figure it out for ts files, but it's somewhat risky... it might replace stuff it shouldn't. However risky it is for TS, it's much more so to apply it to all JS files. I tried and it immediately broke some other unrelated files. There isn't any foolproof way to regex both TS and JS files and only find I talked with the team and the immediate solution is that libs should be distributed with inlined html/css. The solution in the near future is is for libs to be build with I'm closing the issue then since this isn't a CLI bug per se, but rather a bigger topic that needs to be discussed in the docs or angular/angular issues. |
How about things such as images that I library may include? Will it be covered by ngc as well? Also do you have any links to the discussions you mentioned? Thank you. |
Actually, this is as good as any a place to discuss all this, reopening. I don't have any links to the discussions, it's ongoing. |
@filipesilva I have similar problem I've described in #3274 (comment) |
A couple of months have passed since this issue was opened and even though there isn't much more to say, I want to give an update before closing it. As far as libraries go, they should always inline html and css and be AoT ready. There isn't yet a published chapter about this on angular.io, but there's one in the works that needs a bit more work: angular/angular.io#2758 Images and other resources have to either be inlined, or somehow provided for the application to use. TSC doesn't do anything with these, as far as I know. When the CLI has a library move (tracked in #1692) it should do all of this for you. Until then third party libraries have to do it themselves without the CLI. |
Why don't you add a custom loader in webpack that does the replace example: or you allow adding custom loaders to the webpack in the cli? |
Because that regex replacement might look fine for Angular components, but will also break any other third party library that happens to use those strings. We tried regex replacements for a while, and it's really not worth it. There's also no decent way to figure out which JS or TS files are Angular components. |
The modules that would require something like that could be explicitly configured somewhere in the package.json with the others angular-cli options, also I suppose are not a lot the modules that would require something like that. example package.json :
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Mac OSX El Capitan
angular-cli: local (v1.0.0-beta.11-webpack, branch: ??)
node: 6.3.1
os: darwin x64
more information.
This worked pre the switch to using webpack instead of broccoli.
The text was updated successfully, but these errors were encountered: