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

@vitejs/plugin-legacy 4.0.0 broken #11898

Closed
7 tasks done
erkib opened this issue Feb 2, 2023 · 2 comments
Closed
7 tasks done

@vitejs/plugin-legacy 4.0.0 broken #11898

erkib opened this issue Feb 2, 2023 · 2 comments

Comments

@erkib
Copy link

erkib commented Feb 2, 2023

Describe the bug

I upgraded the @vitejs/plugin-legacy to version 4.0.0 and now dev server is unable to start. Error shown:
SyntaxError: Named export 'loadConfig' not found. The requested module 'browserslist' is a CommonJS module, which may not support all module.exports as named exports.

Problem lies in file index.mjs
When I changed the import { loadConfig } from 'browserlist' to:
import pkg from 'browserslist';
const { loadConfig } = pkg;
Now the dev server is able to start normally.

Reproduction

None

Steps to reproduce

Just upgrade the plugin to 4.0.0

System Info

System:
    OS: macOS 13.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 9.73 GB / 32.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 19.5.0 - /opt/homebrew/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 9.3.1 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 109.0.5414.119
    Safari: 16.3
  npmPackages:
    @vitejs/plugin-legacy: ^4.0.0 => 4.0.0
    @vitejs/plugin-react: ^3.1.0 => 3.1.0
    vite: ^4.1.0 => 4.1.0

Used Package Manager

npm

Logs

No response

Validations

@erkib erkib changed the title @vitejs/plugin-legacy broken @vitejs/plugin-legacy 4.0.0 broken Feb 2, 2023
@ModyQyW
Copy link
Contributor

ModyQyW commented Feb 2, 2023

Same here.

@ModyQyW
Copy link
Contributor

ModyQyW commented Feb 2, 2023

Just created a PR #11899.

v3.0.2 works fine for me.

For temporary fix, update node_modules/@vitejs/plugin-legacy/dist/index.mjs like below.

Before:

import { loadConfig } from 'browserslist';

After:

import browserslist from 'browserslist';
const { loadConfig } = browserslist;

@github-actions github-actions bot locked and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants