parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.53k stars 2.27k forks source link

Uncaught ReferenceError when module.exports = fn is used #6008

Open typeofweb opened 3 years ago

typeofweb commented 3 years ago

🐛 bug report

Uncaught ReferenceError when importing a package with module.exports = fn

Screenshot 2021-03-17 at 16 46 38

🎛 Configuration (.babelrc, package.json, cli command)

(repository below)

🤔 Expected Behavior

The error should not be thrown.

😯 Current Behavior

Error thrown.

💁 Possible Solution

The problem is caused by these two lines:

module.exports = insertCss;
module.exports.insertCss = insertCss;

I managed to "fix" it manually modifying the dependency of ant-design and deleting the first line: https://github.com/mmiszy/insert-css/commit/e3d3733e466668df2b94074809d6c6cc163f8269#diff-e727e4bdf3657fd1d798edcd6b099d6e092f8573cba266154583a746bba0f346L57

💻 Code Sample

https://github.com/mmiszy/parcel-problem-reproduction2

Steps to reproduce:

npm i
npm run build:client
cd dist/client
npx http-server

Then go to http://127.0.0.1:8080 and open devtools to see the error.

p-baum commented 3 years ago

I'm new to this bundling world so correct me if im wrong here. I am trying to use Google material.io components but I am getting the followng error:

@parcel/transformer-sass: expected "{".
   ╷
10 │         module.exports = factory();
   │                                   ^
   ╵
  node_modules/@material/drawer/dist/mdc.drawer.js 10:29  @use
  src/main.scss 1:1                                       root stylesheet

It would appear to be a showstopper for material design sass from google. (I got the javascript hotloading working)

I really really dont want to have to use webpack. Can anybody help?

DeMoorJasper commented 3 years ago

@p-baum this error seems unrelated to the issue, can you please open a new issue with a reproducible test case