adding es module script in index.html have error >> does not provide an export named 'parse'
See original GitHub issueDo NOT ignore this template or your issue will have a very high chance to be closed without comment.
Describe the bug
Adding ES Module script in index.html encounter error (index):1 Uncaught SyntaxError: ‘/@modules/@babel/parser/lib/index.js’ does not provide an export named ‘parse’
Not sure if this is really the vite issue (maybe the @vue/compiler-core@3.0.0-rc.5) but i just import {mount} from ‘@vue/test-utils’ which has dependency on @vue/compiler-dom@3.0.0-rc.5 which has dependency on @vue/compiler-core@3.0.0-rc.5 which has dependency on @babel/parse dependency
Reproduction
- npx create-vite-app sample
- cd sample
- change version of vue,@vue/compiler-sfc to 3.0.0-rc.5, vite to 1.0.0-rc.4
- yarn install
- yarn add @vue/test-utils@2.0.0-beta.1 --dev
- this is actual index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
<script type="module">
import { mount } from '@vue/test-utils'
</script>
</body>
</html>
- yarn dev
System Info
- required
vite
version: 1.0.0.rc.4 - required Operating System: MacOSX
- required Node version: 14
- Optional:
- npm/yarn version
- Installed
vue
version (fromyarn.lock
orpackage-lock.json
) - 3.0.0-rc.5 - Installed
@vue/compiler-sfc
version - 3.0.0-rc.5
Logs (Optional if provided reproduction)
- Run
vite
orvite build
with the--debug
flag. - Provide the error log here.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
42 - Stack Overflow
Uncaught SyntaxError: The requested module './add.js' does not provide an export named 'add' ; See the export default ? So it's a default...
Read more >Misleading error that module does not provide export #32137
cjs' does not provide an export named 'name' which is only "true" because ES modules aren't allowed to import CJS named exports.
Read more >Requested module does not provide export named 'default'
The error "The requested module does not provide an export named 'default'" occurs when we try to import a value or a function...
Read more >the requested module 'path' does not provide an export ...
With ESM modules, there are two ways to export functionnalities: either as default exports, or as named exports. The way you import these...
Read more >JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript module syntax. A background on modules. JavaScript programs started off pretty ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It caused by https://github.com/vuejs/vue-test-utils-next/blob/19bc8a784b7a18c729ebfe0aeef73b0a6b812285/src/utils/compileSlots.ts#L1-L2. The VTU used
compile
(include babel) with runtime.@aelbore . You can add
vue-test-utils
intooptimizeDeps
to fix it.@underfin thanks it works for me adding vue-test-utils in optmizeDeps basically vite create a bundle for vue-test-utils including its dependencies.