-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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 Redefine property" error when importing #3415
Comments
This doesn't appear to be a webpack related error. Is this an issue with typescript seeing a reimport or redefine of this property? |
Hi @TheLarkInn, What make you think it's a typescript issue? I suspect webpack because:
|
Did a slightly deeper dive into the problem. I can stop the error from occurring by not re-exporting Let me explain by briefly showing the directory tree where ng-table (root directory) index.ts +- src +- core index.ts ngTableParams.ts Here are the relevant exports that collectively are causing the problem it would seem: // src/core/ngTableParams.ts
export class NgTableParams<T> { } // src/core/index.ts
export * from './ngTableParams'; // index.ts (at the root of the package)
export * from './src/core'; To "fix" things I have to stop re-exporting // src/core/ngTableParams.ts
export class NgTableParams<T> { } // src/core/index.ts
export { NgTableParams } from './ngTableParams'; // index.ts (at the root of the package)
export { NgTableParams } from './src/core/ngTableParams'; With the above in place the demo-app runs without error. I have committed the above change to another ng-table branch for comparison (here's the exact: commit) Even more detailsBelow is a screenshot of the relevant portion of the webpack bundle that fails. The line of code that is throwing is shown highlighted in blue: Below is a screenshot of the same portion of the webpack bundle after applying the workaround of not re-exporting as explained above: |
I have been able to reduce the problem down further. The problem occurs even with a single Here's are the relevant changes: // src/core/ngTableParams.ts
export class NgTableParams<T> { } // src/core/index.ts
export * from './ngTableParams'; // demo-app
// this fails at runtime with error "Cannot redefine property: NgTableParams"
import { NgTableParams } from 'ng-table/src/core'; The commit with the simplified code: esvit/ng-table@a992e82 |
Workaround to webpack issue: webpack/webpack#3415
Ah I see the issue. I need the check the spec to see if the app or webpack is wrong here... |
Looks like webpack is wrong here.
|
OK thanks Tobias for checking the problem out. |
Workaround to webpack issue: webpack/webpack#3415
Thank you for the detailed report. Made this much easier to fix!! |
To add to it: explicit exports take precedence over reexports (e.g. |
Correction: They are only allowed when they resolve to the same binding. see http://www.ecma-international.org/ecma-262/6.0/#sec-resolveexport |
Thanks for the very quick turnaround @sokra. Do you know when you're intending to publish the next release? |
We are waiting on a few things to merge before we release. The next release is potentially looking to be an RC. |
OK thanks for the heads up |
Workaround to webpack issue: webpack/webpack#3415
Workaround to webpack issue: webpack/webpack#3415
Do you want to request a feature or report a bug?
Bug report
What is the current behavior?
The following import statement:
produces the following error logged to the console:
If the current behavior is a bug, please provide the steps to reproduce.
Run the demo-app in ng-table where the above import is attempted:
The last command will use
webpack-dev-server
to launch the demo-app in your default browser.In chrome this produces the error logged to the console.
What is the expected behavior?
The import of
NgTableParams
should workPlease mention other relevant information such as the browser version, Node.js version, Operating System and programming language.
Possible related to: #2953
Environment details
The text was updated successfully, but these errors were encountered: