miragejs / miragejs

A client-side server to build, test and share your JavaScript app
https://miragejs.com/
MIT License
5.36k stars 166 forks source link

Issue importing lodash #1058

Open HalfdanJ opened 1 year ago

HalfdanJ commented 1 year ago

I'm trying to use miragejs, but getting blocked by a runtime syntax error.

The project is using @web/dev-server as dev server, with esbuild plugin, and is written in typescript.

When importing miragejs, i get a runtime error

Uncaught SyntaxError: The requested module './../../lodash.assign/index.js' does not provide an export named 'default' (at mirage-esm.js:20:8)

If I look at the code in mirage-esm, I see

...
import assign from './../../lodash.assign/index.js';
...

And if I look inside that file is see

...
module.exports = assign;

which to me seems not to be correct. Theres no default export, as the mirage code expects.

HalfdanJ commented 1 year ago

Since mirage is written as an esm module, shouldn't it depend on lodash-es instead?

JS-Coriander commented 1 year ago

Hi, I got the same error, did you solve it?

amekusa commented 1 year ago

Maybe the same error I got, trying to bundle with rollup:

RollupError: "default" is not exported by "node_modules/lodash.uniq/index.js", imported by "node_modules/miragejs/dist/mirage-esm.js"
import { createServer, Model, Factory } from 'miragejs';

v0.1.47