zodern / melte

Svelte compiler for Meteor with built in tracker integration and HMR
MIT License
33 stars 14 forks source link

Cordova arch error #3

Closed boomfly closed 3 years ago

boomfly commented 3 years ago

If build cordova targets get error:

Uncaught TypeError: Class constructor SvelteComponentDev cannot be invoked without 'new'

https://github.com/meteor/meteor/blob/c7534dbcddd3c677efb6297e67132b05bd63dc87/packages/babel-compiler/babel-compiler.js#L90

This line makes modernBrowsers only for web.browser arch, but svelte need it if we compile web.cordova

r00t3g commented 3 years ago

There is a work around how to make babel proprly transpile svelte's internals: https://forums.meteor.com/t/transpile-certain-node-modules-with-babel-at-meteor-build/48546

You just need to link the svelte package from node-modules inside any of meteor-watchable directories, e.g. /imports

zodern commented 3 years ago

I don't have a cordova project to test with, but if anyone wants to, feel free to submit a PR documenting how to fix this.

r00t3g commented 3 years ago

I am not sure that it is really a melte problem as it seems to be related to the way meteor-babel handles node_modules imports... However, it is possible to reproduce it without cordova, using some legacy browser (ie 11 would do). I'll try to have a look at it - perhaps will find something

zodern commented 3 years ago

Thanks @r00t3g. I tried the legacy client, and melte itself also caused syntax errors. I published zodern:melte@1.4.1 to fix that, and also document how to have Meteor recompile svelte.