kiliman / remix-express-vite-plugin

This package includes a Vite plugin to use in your Remix app. It configures an Express server for both development and production using TypeScript.
118 stars 6 forks source link

Named export "minimatch" not found #16

Closed AndresRodH closed 3 months ago

AndresRodH commented 3 months ago

Hello! I have a monorepo setup and I stumbled upon this issue when migrating my custom server.ts to the plugin.

failed to load config from /Users/arodriguez/Code/coolfire/apps/web/vite.config.ts
error when starting dev server:
file:///Users/arodriguez/Code/coolfire/node_modules/remix-express-dev-server/dist/index.js:1
import { minimatch } from 'minimatch';
         ^^^^^^^^^
SyntaxError: Named export 'minimatch' not found. The requested module 'minimatch' 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 'minimatch';
const { minimatch } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadConfigFromBundledFile (file:///Users/arodriguez/Code/coolfire/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:68705:21)
    at async loadConfigFromFile (file:///Users/arodriguez/Code/coolfire/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:68558:28)
    at async resolveConfig (file:///Users/arodriguez/Code/coolfire/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:68161:28)
    at async _createServer (file:///Users/arodriguez/Code/coolfire/node_modules/vite/dist/node/chunks/dep-cNe07EU9.js:64686:20)
    at async CAC.<anonymous> (file:///Users/arodriguez/Code/coolfire/node_modules/vite/dist/node/cli.js:762:24)

I have double checked my setup to follow what the example app does, but unfortunately I kept running into the same issue. I fixed the issue manually with a patch:

-import { minimatch } from 'minimatch';
+import pkg from 'minimatch';
+const { minimatch } = pkg;
thomaswelton commented 3 months ago

Link to discord https://discord.com/channels/770287896669978684/1234277397549944894/1240316724268498945

If you were to install minimatch as a dev dependency that would also resolve the issue