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

Cannot redeclare block-scoped variable 'ngDevMode' - Back with Angular 5.2.3 #10

Open
erickbrenesLT opened this issue Feb 1, 2018 · 24 comments

Comments

@erickbrenesLT
Copy link
Contributor

erickbrenesLT commented Feb 1, 2018

@tiaguinho Getting this error.
ionic serve fails in Angular 5.2.3, Ionic 4.5.3, Ionic2-Mask 1.0.8
typescript: node_modules//src/render3/ng_dev_mode.d.ts, line: 9
Cannot redeclare block-scoped variable 'ngDevMode'.

typescript: ...es/ionic2-mask-directive/node_modules//src/render3/ng_dev_mode.d.ts, line: 9
Cannot redeclare block-scoped variable 'ngDevMode'.

@erickbrenesLT
Copy link
Contributor Author

erickbrenesLT commented Feb 5, 2018

@tiaguinho this happens with angular core. If I downgrade just angular core to 5.2.2 - it works. The ngDevMode is seeing a global declaration of itself when it comes to project dependencies and this lib's dependencies and when you have two different angular versions 5.2.2 vs 5.2.3.

@okonon
Copy link

okonon commented Feb 5, 2018

same here @tiaguinho

@erickbrenesLT
Copy link
Contributor Author

@tiaguinho Need a solution that prevents future upgrading from colliding.

@tiaguinho
Copy link
Owner

I'm trying to fix this problem.
I'm changing the dependencies and transform the directive in a module.
I'll try to publish a new version until tomorrow.

@erickbrenesLT
Copy link
Contributor Author

@tiaguinho any luck?

@erickbrenesLT
Copy link
Contributor Author

@tiaguinho angular just updated to 5.2.4 - still an issue with core. Have to stay on 5.2.2 to avoid the error.

@erickbrenesLT
Copy link
Contributor Author

@tiaguinho getting a typescript error with AOT again - not sure if it's related. Here is info on it maybe - angular/angular#15767

typescript error
Error during template compile of 'Ionic2MaskDirective' Function calls are not supported in decorators but 'ɵmakeDecorator' was called in 'Directive' 'Directive' calls 'ɵmakeDecorator'.

[10:21:47] ionic-app-script task: "build"
[10:21:47] Error: The Angular AoT build failed. See the issues above
Error: The Angular AoT build failed. See the issues above
at /Users/erickbrenes/Sites/site/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:237:55
at step (/Users/erickbrenes/Sites/site/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:32:23)
at Object.next (/Users/erickbrenes/Sites/site/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:13:53)
at fulfilled (/Users/erickbrenes/Sites/site/node_modules/@ionic/app-scripts/dist/aot/aot-compiler.js:4:58)
at

@erickbrenesLT
Copy link
Contributor Author

@tiaguinho have you had a chance to update it?

@okonon
Copy link

okonon commented Feb 12, 2018

@tiaguinho thanks for your great work!

@erickbrenesLT
Copy link
Contributor Author

@tiaguinho upgraded to Angular 5.2.5 core and it's still an issue. Any progress with updating the app? At the very least can you release a version with the dependencies at 5.2.5 until you complete the fix.

@erickbrenesLT
Copy link
Contributor Author

@tiaguinho can you release a version with the dependencies at 5.2.5 until you complete the fix.

@okonon
Copy link

okonon commented Feb 15, 2018

@tiaguinho i was wondering if you had any updates regarding this? Thanks

@tiaguinho
Copy link
Owner

This week was crazy, so I'll try to finish this on the weekend.
Sorry for the delay.

@okonon
Copy link

okonon commented Feb 15, 2018

no problem thanks for your help

@erickbrenesLT
Copy link
Contributor Author

@tiaguinho any progress?

@okonon
Copy link

okonon commented Feb 20, 2018

also interested @tiaguinho

@erickbrenesLT
Copy link
Contributor Author

@tiaguinho still an issue with core 5.2.6

@erickbrenesLT
Copy link
Contributor Author

@tiaguinho also with 6.0.0-beta.5 (2018-02-22) core it breaks.

@erickbrenesLT
Copy link
Contributor Author

@tiaguinho @TalissonJunior any updates on fixing this or at least updating it to handle angular 5.2.7 for the time being?

@erickbrenesLT
Copy link
Contributor Author

@tiaguinho @TalissonJunior Still an issue with 5.2.8 as expected. Any updates?

@agnosticdev
Copy link

@tiaguinho also would be interested in this.

@erickbrenesLT
Copy link
Contributor Author

@tiaguinho @TalissonJunior Any update?

@adrianowead
Copy link

It's not a issue from this project.
It's a angular issue.

angular/angular#21670

It's a conflict, because this repo and the ionic uses the angular/core, and same constant are declareted when typescript build the node_modules folder.

@erickbrenesLT
Copy link
Contributor Author

erickbrenesLT commented Apr 20, 2018

I don't know if I would say it's an angular issue perse. I see that they mention a couple solutions:

  1. TS2451: Cannot redeclare block-scoped variable 'ngDevMode'. angular/angular#21925
  2. error TS2451: Cannot redeclare block-scoped variable 'ngDevMode' angular/angular#21670 (comment)

Quote form 1. That might help. "The problem is fundamentally here,

"paths": {
"Utils/": ["../module/src/utils/"]
}
This causes TypeScript to bring in both the @angular/core from ../modules/node_modules/@angular/core as well as the @angular/core from ./node_modules/@angular/core. This has never been supported and errors produced in this configuration are not considered regressions as the scenario is not support, it just happened not to break for you until 5.2. There are several cases where this would have broken your code earlier, you just didn't hit them. To state this more clearly, we don't support having two different versions of angular definitions in the same compilation.

The simple way around this is to have module and app share the same copy of angular instead of having there own. In other words, move the package.json up one directory.

If you require to have a separate compilation then I recommend using something like ng-packgr to help build the module directory as a package. This package can then be installed into the node_modules of app.

We are working to improve the ergonomics of libraries and is one of our primary focuses for this release cycle. For now, however, you need to ensure that only one copy of angular is found by the compiler or separately compile the modules using ng-packgr."

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

No branches or pull requests

5 participants