modernweb-dev / web

Guides, tools and libraries for modern web development.
https://modern-web.dev
MIT License
2.21k stars 288 forks source link

[plugin-commonjs] Cannot resolve import #2248

Open jost-s opened 1 year ago

jost-s commented 1 year ago

When using web dev server, the rollup plugin for CommonJS cannot resolve an import.

The exact error message is

PluginError: Could not resolve import "tls"

I expect for the common js plugin to handle the module correctly inside of WDS.

Bundling the same file with rollup doesn't cause errors, neither during bundling nor execution.

A minimal reproduction https://github.com/jost-s/wds-common-js-error

To produce the error, run npm start. To compare with the rollup command execution, run npm run bundle.

Westbrook commented 1 year ago

The Common JS Plugin for Rollup has many and varied options for the various flavors and failing of CJS that remain in the ecosystem, please be sure to explore all of them and how they may apply to the specific dependencies you are consuming in this context.