Skip to content
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

Vite build fails with [SyntaxError: Unexpected token 'export'] #46

Closed
thmr opened this issue Jul 24, 2022 · 7 comments
Closed

Vite build fails with [SyntaxError: Unexpected token 'export'] #46

thmr opened this issue Jul 24, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@thmr
Copy link

thmr commented Jul 24, 2022

(node:87751) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
/some/folder/node_modules/mapbox-gl-controls/lib/index.js:1
export { default as CompassControl } from './CompassControl/CompassControl';
^^^^^^

SyntaxError: Unexpected token 'export'
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at ModuleWrap. (node:internal/modules/esm/translators:196:29)
at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
at async Loader.import (node:internal/modules/esm/loader:178:24)
at async Promise.all (index 1)
[SyntaxError: Unexpected token 'export']

@korywka
Copy link
Owner

korywka commented Jul 24, 2022

Please provide some minimal project with failed build. It can be a bug in my project, bug in Vite, or mistake in build configuration. Vite also has 2 versions right now. Without minimal project I can't reproduce this error and have to close this issue. Thanks.

@thmr
Copy link
Author

thmr commented Jul 24, 2022

Thank you! I will prepare a minimal project shortly.

@thmr
Copy link
Author

thmr commented Jul 24, 2022

@korywka
Copy link
Owner

korywka commented Jul 29, 2022

Thanks. Vite wants ES6 build. I will do it in v2. Sorry, but too much to do to fix v1. v2 is coming in the future.

For now you can try import controls like

import ZoomControl from 'mapbox-gl-controls/src/ZoomControl/ZoomControl';

@korywka korywka added the enhancement New feature or request label Jul 29, 2022
@korywka
Copy link
Owner

korywka commented Jul 29, 2022

Should fix also #31

@thmr
Copy link
Author

thmr commented Jul 31, 2022

The proposed temporary solution worked out - thanks!

@korywka
Copy link
Owner

korywka commented Oct 4, 2023

All code is ES6 now. Hope Vite will not give any errors.

@korywka korywka closed this as completed Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants