question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

adding es module script in index.html have error >> does not provide an export named 'parse'

See original GitHub issue

Do 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

  1. npx create-vite-app sample
  2. cd sample
  3. change version of vue,@vue/compiler-sfc to 3.0.0-rc.5, vite to 1.0.0-rc.4
  4. yarn install
  5. yarn add @vue/test-utils@2.0.0-beta.1 --dev
  6. 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>
  1. yarn dev

alt text

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 (from yarn.lock or package-lock.json) - 3.0.0-rc.5
    • Installed @vue/compiler-sfc version - 3.0.0-rc.5

Logs (Optional if provided reproduction)

  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
underfincommented, Aug 5, 2020

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 into optimizeDeps to fix it.

0reactions
aelborecommented, Aug 5, 2020

@underfin thanks it works for me adding vue-test-utils in optmizeDeps basically vite create a bundle for vue-test-utils including its dependencies.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found