-
-
Notifications
You must be signed in to change notification settings - Fork 33.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
Missing default export when using SystemJS or RequireJS makes Vue unusable with TypeScript #6815
Comments
I am mostly certain this is a problem with your setup. I'm not familiar with SystemJS but you probably want to adjust this to use the ES modules build ( |
Vue's declaration is now switched to ES module style declaration and we need to use |
If I switch SystemJS to use .esm.js then I have to add a (pointless) babel plugin to transpile the compiled JS. And If I do that, then SystemJS will complain that "process" is undefined: I cannot fix that in my config, since the meta/globals override config is only supported under "cjs" and "global" module formats. This is driving me slightly mad. It seems to me that this could be fixed with a simple ping @ktsn @DanielRosenwasser |
The |
I am trying to shim it right here: https://github.com/ciddan/vue-2.5-issues/blob/7e4dad6f81a8d4c21c7c76fb794738f69fcafddb/system.config.js#L25 But I suppose I'll just have to include this thing in
|
Maybe I'm missing something, but my understanding was that SystemJS gives you the "intended" behavior with default imports, but you need to turn on TypeScript's |
Just to boil this down into a simple example:
vue_1 is the constructor function, vue_1.default is undefined. |
Looks like you're emitting to CommonJS which by default doesn't do any sort of default synthesis. Since you're already targeting SystemJS, you might as well switch your |
I'm not familiar with SystemJS. But from this thread, it seems that SystemJS's author think that default synthesis should be handled by transpiler. And I'm quite sure TypeScript does not handle synthesis by design. You do need another transpiler for now. Or trying out Daniel's suggestion listed in the thread linked above. |
Thanks @DanielRosenwasser. That did the trick. I wasn't aware of the System-specific module target. |
@ciddan You deleted repo https://github.com/ciddan/vue-2.5-issues |
Just solved in my repo. |
Version
2.5.2
Reproduction link
https://github.com/ciddan/vue-2.5-issues
Steps to reproduce
The project is configured to use SystemJS by default. You can switch to RequireJS by modifying index.html and src/login/Login.ts and uncommenting the RequireJS code (and commenting out the SystemJS code).
What is expected?
No errors in console and vue_1.default being defined.
What is actually happening?
SystemJS (Firefox Developer Edition):
Error: class heritage vue_1.default is not an object or null
Evaluating http://localhost:8080/dist/src/login/Login.js
Loading app.bootstrap.js
RequireJS (Firefox Developer Edition):
TypeError: class heritage vue_1.default is not an object or null
This bug appeared after upgrading a major project from Vue 2.4 to Vue 2.5.
We do not use Webpack in our project, nor do we want to switch to it.
The text was updated successfully, but these errors were encountered: