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

Can't figure out how to use cubing.js with vite dev server #215

Closed
anicolao opened this issue Sep 7, 2022 · 4 comments
Closed

Can't figure out how to use cubing.js with vite dev server #215

anicolao opened this issue Sep 7, 2022 · 4 comments

Comments

@anicolao
Copy link
Contributor

anicolao commented Sep 7, 2022

To Reproduce

  1. Start a new project using vite as the build tool
  2. Modify the config file to specify es2020 as the build target
import { sveltekit } from '@sveltejs/kit/vite';

/** @type {import('vite').UserConfig} */
const config = {
	plugins: [sveltekit()],
	build: {target: "es2020"}
};

export default config;
  1. Verify vite build works on cubing
  2. Run vite dev and die on bigint issues
✘ [ERROR] Big integer literals are not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari13" + 2 overrides)

    node_modules/cubing/dist/esm/puzzle-geometry/index.js:636:10:
      636 │   let r = 1n;
          ╵           ~~
...

Expected behavior
I expected the vite config to work for both build and dev.

@anicolao
Copy link
Contributor Author

anicolao commented Sep 7, 2022

Workaround: #216

@lgarron
Copy link
Member

lgarron commented Sep 9, 2022

Vite has made... some "interesting" choices regarding compat. Per https://js.cubing.net/cubing/#javascript , you need:

// vite.config.js
export default { optimizeDeps: { esbuildOptions: { target: "es2020" } } };

(But thanks for the PR, that might not be necessary anymore.)

@lgarron
Copy link
Member

lgarron commented Sep 9, 2022

Okay, I've checked and we work with Vite 3 out of the box.

@lgarron lgarron closed this as completed Sep 9, 2022
@anicolao
Copy link
Contributor Author

anicolao commented Sep 9, 2022

Yes, I verified both: that adding the config you suggested like this:

import { sveltekit } from '@sveltejs/kit/vite';

/** @type {import('vite').UserConfig} */
const config = {
	plugins: [sveltekit()],
	build: { target: 'es2020' },
	test: { include: ['src/**/*.unit.ts'] },
	optimizeDeps: { esbuildOptions: { target: "es2020" } }
};

export default config;

will fix it for v 0.29.0, and that updating to v 0.29.1 works out of the box with the workaround.

FWIW I still think the workaround is "necessary" in that it's quite hard to figure out what's going wrong here, and there's no meaningful performance or readability penalty to the workaround. So it'll save library users time and effort ... I looked at this config, saw the build target was es2020 and quickly gave up trying to figure out why it wasn't working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants