Closed Westlifers closed 9 months ago
Could you share a project code with a repro case?
Vite should work just fine, since it's using esbuild
, but bundlers do all sorts of shenanigans with some code. commonjs--resolver
is particularly suspicious, since we don't publish any CommonJS files.
I'm also able to confirm that the following works with npm create vue
using TypeScript:
import { randomScrambleForEvent } from "cubing/scramble";
(await randomScrambleForEvent("333")).log();
@lgarron https://github.com/Westlifers/build-failure-example/tree/master here is a demo I just created following the 4 steps I mentioned. I added a line
import {randomScrambleForEvent} from "cubing/scramble"
in `src/components/HelloWorld.vue
run git clone -b master https://github.com/Westlifers/build-failure-example/
then npm install
and npm run build
, it should throw an error. at least on my computer it was the case. idk if that will happen on yours?
btw I found this in console when I'm running npm run dev
browsing a page using randomScrambleForEvent
:
the last two is normal warning while the first three is not.
how I use it:
const scramble:Ref<string> = ref((await randomScrambleForEvent(translateEventForScramble(event.value))).toString())
this code run fine when using webpack...
not sure if this will help... (the scramble was generated correctly even though there are these warnings)
Interesting, it looks like this is because npx vite serve
bundler things significantly differently from npx vite build
.
Specifically, it's failing to handle the direct worker instantiation correctly:
This is 100% valid unambiguous standardized vanilla JS code, so I'll have to follow up with Vite about what's going on.
Filed an issue at: https://github.com/vitejs/vite/issues/14499
@Westlifers: The Vite config at https://github.com/vitejs/vite/issues/14499#issuecomment-1740267849 might work for you.
@lgarron Thanks a lot, that solved the problem!
Steps to reproduce the issue
npm create vue@latest
, with typescript and other options you like chosen. then install dependenciesnpm install cubing --save
import {randomScrambleForEvent} from "cubing/scramble"
in<script>
tagObserved behaviour
🖼 Screenshots
No response
Expected behaviour
build should success without error
Environment
on windows 10
Additional info
only 'cubing/scramble' will cause this error, whild twisty don't, it worked well. btw,
npm run dev
works without error, only build fails.