antfu / vite-plugin-glob

The design experiment for import.meta.glob from Vite.
MIT License
164 stars 6 forks source link

package.json type module #20

Closed jrson83 closed 2 years ago

jrson83 commented 2 years ago

When using type: module in my projects package.json, I get the following error:

❯ npm run dev

> vite-plugin-glob-test@0.0.0 dev
> vite

failed to load config from D:\______mono\jrson.de\vite-plugin-glob-test\vite.config.ts
error when starting dev server:
file:///D:/______mono/jrson.de/vite-plugin-glob-test/node_modules/vite-plugin-glob/dist/index.mjs:1
import { scan, isMatch } from 'micromatch';
               ^^^^^^^
SyntaxError: Named export 'isMatch' not found. The requested module 'micromatch' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'micromatch';
const { scan, isMatch } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:128:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:194:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:409:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at async loadConfigFromFile (D:\______mono\jrson.de\vite-plugin-glob-test\node_modules\vite\dist\node\chunks\dep-3397b401.js:61680:31)
    at async resolveConfig (D:\______mono\jrson.de\vite-plugin-glob-test\node_modules\vite\dist\node\chunks\dep-3397b401.js:61224:28)
    at async createServer (D:\______mono\jrson.de\vite-plugin-glob-test\node_modules\vite\dist\node\chunks\dep-3397b401.js:59636:20)
    at async CAC.<anonymous> (D:\______mono\jrson.de\vite-plugin-glob-test\node_modules\vite\dist\node\cli.js:688:24)

I created a minimal setup for reproduction with create vite & preact-ts.

https://github.com/jrson83/vite-plugin-glob-module-issue

jrson83 commented 2 years ago

Thanks!