angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.56k stars 3.01k forks source link

Import in angularjs 1.6.5 using webpack 4.16.5 does not work as expected. #3749

Closed andreikun closed 4 years ago

andreikun commented 5 years ago

My version of UI-Router is: (type version)

v1.0.20 in conjunction with AngularJs 1.6.5 and webpack 4.16.5

Bug Report

Current Behavior:

When trying to import "@uirouter/angularjs" into my app.js, I get in some cases an error in console saying that "Cannot assign to read only property 'exports' of object '#'". This might be caused by the fact that Webpack does not allow both import and module.exports in the same file, which Webpack actually does by relying heavy on module.exports. I am excluding node_modules from my webpack configuration for babel-loader but still get this error. Might be because is .ts ? I get no issues when building this, nor any error in console for Windows machines, but it breaks on Linux machines when opening the web page - and therefore return this console error "Cannot assign to read only property 'exports' of object '#'" targeted inside @uirouter/angularks/lib-esm

Expected Behavior:

import "@uirouter/angularjs" should work just fine while importing this in app.js and build with webpack, using a babel-loader that exclues node_modules.

  • [ ] I have already asked my question on StackOverflow and nobody could answer the question

  • [X ] I have already reviewed the sample application for examples of common approaches

  • [X ] I believe my question can only be answered by the UI-Router maintainers

andreikun commented 5 years ago

Tracked the related issue on babel repo and found a good comment around the fix : https://github.com/webpack/webpack/issues/4039#issuecomment-419284940

Managed to insert the sourceType unambiguous but still get the same issue.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues may be reopened.

Thank you for your contributions.