rollup / rollup-plugin-commonjs

This module has moved and is now available at @rollup/plugin-commonjs / https://github.com/rollup/plugins/blob/master/packages/commonjs
MIT License
502 stars 126 forks source link

Null-character in module IDs causes Rollup build to fail #397

Closed slavafomin closed 4 years ago

slavafomin commented 5 years ago

Hello!

Thank you for this great plugin!

However, after adding it to our Rollup configuration, the build started to fail with the following error: TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string or Uint8Array without null bytes. Received '…/node_modules/\u0000commonjsHelpers.js'

Looking at the source files of the plugin, I can see module names like this: var HELPERS_ID = '\0commonjsHelpers.js';.

I believe, the problem is with \0 (\u0000) character in module ID. Why are you using it in the first place?

Thanks!

lukastaegert commented 5 years ago

It is a common convention for Rollup plugins: https://rollupjs.org/guide/en/#conventions

A plugin prefixes the path of a virtual (i.e. non-existing) module that other plugins "should not mess with" (like transforming the code) with a null character. Plugins should adhere to this rule and ignore ids that start with a null character unless they created them.

jwvance commented 5 years ago

I'm running into this issue with the same error message. Is there a known workaround?

TrySound commented 5 years ago

@jwvance Could you show you config?

shellscape commented 4 years ago

Hey folks (this is a canned reply, but we mean it!). Thanks to everyone who participated in this issue. We're getting ready to move this plugin to a new home at https://github.com/rollup/plugins, and we have to do some spring cleaning of the issues to make that happen. We're going to close this one, but it doesn't mean that it's not still valid.

We've got some time yet before the move while we resolve pending Pull Requests, so if this issue is still relevant, please @ me and I'll make sure it gets reopened and transferred to the new repo. :beer: