Akryum / meteor-vite

MIT License
33 stars 16 forks source link

Cannot import from 'meteor/accounts-base' - Uncaught SyntaxError: Unexpected token 'default' #8

Closed red-meadow closed 10 months ago

red-meadow commented 1 year ago

@Akryum , thank you very much for quickly fixing previous issues. Unfortunately, I've found some more. Apart from that, everything works great. I've managed to run a huge Svelte + TailwindCSS project.

The issue is described in the title.

image

image

ThaumRystra commented 1 year ago

I'm having the same issue.

It looks like module re-exports are not catching all default exports and letting default through as an exported key instead: https://github.com/Akryum/meteor-vite/blob/main/packages/vite-bundler/worker-dev.mjs#L108

And probably again here: https://github.com/Akryum/meteor-vite/blob/main/packages/vite-bundler/build.js#L160

diavrank commented 1 year ago

@red-meadow @ThaumRystra you just need to remove the Account imports in the client side to solve that error. Accounts is a global variable, so, your app will work anyway, even without the import statements.

References: https://forums.meteor.com/t/status-of-vue-3-meteor/57915/47?u=diavrank95

mikkelking commented 1 year ago

Meteor appears to be happy with statements like

export default = m2.default

But I am seeing in other place (eg Storybook) that it wants the declaration and default export to be done separately

So in this case

export default m2.default will work

And otherwise if you are doing

export default x = () => 'Something'

You can just do it like this:

const x = () => 'Something'
export default x

Or if you want, it can be done without a local variable in a one-liner

export default () => 'Something'
diavrank commented 1 year ago

I have a working example with Vite 4 and Meteor 2.10.0 here https://github.com/diavrank/theory-swe/pull/5

gunnartorfis commented 1 year ago

@red-meadow @ThaumRystra you just need to remove the Account imports in the client side to solve that error. Accounts is a global variable, so, your app will work anyway, even without the import statements.

References: https://forums.meteor.com/t/status-of-vue-3-meteor/57915/47?u=diavrank95

Confirmed this fixed the issue for me but I also had to remove it from my server part.