Importing source(*.ts) from npm module causes imports to be added twice in main.bundle.js
Environnment : angular-cli: 1.0.0-beta.11-webpack.8 node: 6.2.1 os: win32 x64
On one hand I have a very simple mpm module containing common code to be used by my application. This module is like so :
- package.json
- MyModule.ts
- MyComponent.ts
I only expose the source code. no .js, no node_modules, etc... My module and component import the traditional @angular/* packages.
On the other hand I have a freshly build angular-cli@webpack project into wich I import and use my npm module.
When I build my project main.bundle.js contains lots of definitions twice.
for instance,
var CompileNgModuleMetadata = (function () {...})
or
var Observable = (function () {...})
etc...
This is causing problems when using MyComponent in MyApplication... even though the application compile without complaining. it is failing at Runtime because multiple instance of same imports (Like NgModule) are created.
I guess webpack considers the @angular/* from my AppComponent is different from @angular/* comming from the npm module's source when it shouldn't.
For more details on the case see question on StackOverflow
Are you using different versions of @angular/*? This would cause the end bundles to have duplicates. This might be a case for peerDependency instead of dependency in your package.
@filipesilva , I have the same versions for @angular/ in both package.json/dependencies of the client and package.json/peerDependencies of the npm module:
"peerDependencies": {
"@angular/common": "2.0.0-rc.5",
"@angular/compiler": "2.0.0-rc.5",
"@angular/core": "2.0.0-rc.5",
"@angular/forms": "0.3.0",
"@angular/http": "2.0.0-rc.5",
"@angular/platform-browser": "2.0.0-rc.5",
"@angular/platform-browser-dynamic": "2.0.0-rc.5",
"@angular/router": "3.0.0-rc.1",
"core-js": "^2.4.0",
"rxjs": "5.0.0-beta.11",
"ts-helpers": "^1.1.1",
"zone.js": "0.6.12"
}
but is it really used ?
Removing package.json in my npm module didin't change a thing.
Hi, to explain the same problem, i created a project with angular-cli beta.14. In this project, i would use a module extern (named HomeModule). I give you my zip project example if you want to see the detail @filipesilva . http://www.k-upload.fr/afficher-fichier-2016-09-19-1725db30ftoto.zip.html
@choucry13 reproduces exactly the pb I'm describing ! thanks ;-)
Any news @filipesilva ? We are still blocked on this issue. Looking forward for your findings ! Cheers
@choucry13 @pdelorme Is this problem still current ?
Hi, nop you can close the issue. Than you :-)
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.