-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Proposal: Provide a way to add externals to webpack config #2141
Comments
Something to experiment with (that does not require modification of the CLI itself) is to add a Potential contents of
|
I am interested in this feature as well, for this exact reason. Is this in process? |
@pgkehle the solution provided by @clydin works perfectly, although I am interested on this working out of the box too. |
@alejoar I am working through this, but getting a lot of errors related now to jQuery not found, as my app uses bootstrap v4 and other modules. Curious if there is a working example.
|
@pgkehle you can already use bootstrap4, see https://github.com/angular/angular-cli#global-library-installation. The problem shown in this issue is specific to how dependencies used in both |
@clydin Your fix does not seem to work for me in Firefox 49 but works in Chrome 53. But I had to use $('#calendar').fullCalendar in ngAfterViewChecked and not after ngAfterViewInit (for Firefox and with my PR). So maybe I misused life cycle hooks with the scrolltofixed plugin. Anyway, either your fix does not work with Firefox or lifecycle hooks works differently between Chrome and Firefox. Did you test your fix with Firefox? When do you use jQuery plugins? ngAfterViewInit or ngAfterViewChecked? |
I have the exact same issue with almost (not the same calendar package) the same case with moment. |
So #3814 fixes this issue, but not by adding externals. Rather, it fixes a bug that forced files listed as scripts to always be loaded as a string via |
I'd like to note that, since this is NOT the externals functionality, if you want to use the global instance you will need to still I'd prefer to not add externals because it forces people to figure out how some libs work and what they export. For some libs that's really hard to tell. I think it's overall preferable to just have feature parity with script tags which is a much simpler concept to understand, explain and use. |
I still require externals for using Angular 2 with Electron. For example, i'm using an npm library called 'drivelist' which calls a node 'child_process'. The only way I could get this to work with ng-serve is to make 'drivelist' external and have Electron load the module. For ng serve, i included the external like this to work: externals: {
Then in Electron, i'm just loading the ng serve url: win = new BrowserWindow({width: 800, height: 600}) |
I have an issue that is kind of related. |
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. |
The issue is that if I use global script via app[0].scripts I cannot use it again in my .ts files.
Example: if I have:
I cannot do:
import * as moment from 'moment';
. If I do so, moment will become an empty object. Of course, I can use it without importing it since it is global BUT other libs that depends on moment (angular2-moment in my case) will doimport * as moment from 'moment';
, they will get an empty object and their code will break.Then I cannot use this libs. (I think #1974 is related)
I cannot remove moment from scripts since I have other global scripts that depend on it (fullcalendar). Maybe there is a way to make all this scripts work without apps[0].scripts but I have not found it.
My solution is to use webpack externals https://webpack.github.io/docs/library-and-externals.html
If I add
to
webpack-build-common.ts
it is working.I can provide a PR adding externals from
apps[0].externals
to the webpack config. Is it the right solution?The text was updated successfully, but these errors were encountered: