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

boolean export word gives an error #398

Closed vladshcherbin closed 5 years ago

vladshcherbin commented 5 years ago

Hey, 👋

I have an error when using yup package:

[!] Error: 'boolean' is not exported by node_modules/yup/lib/index.js
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module-
src/index.js (5:9)
3: // console.log(string)
4: 
5: import { boolean } from 'yup'
            ^
6: 
7: console.log(boolean)

It says boolean is not exported. However, in source code in node_modules it is clearly exported:

image

All other imports from this package work except this one. Strange part is that I can rename it to any other name (boolean1, booleana or smth) and it will successfully import and use it.

Is boolean word somehow reserved or what can cause this problem? 🤔


rollup - 1.16.4 rollup-plugin-node-resolve - 5.2.0 rollup-plugin-commonjs - 10.0.1 reproduction - repo with demo

vladshcherbin commented 5 years ago

Hm, there is actually a reserved list of words and it has boolean in it.

What's the advice in this case?

cc @lukastaegert

lukastaegert commented 5 years ago

My advice would be to use the default export and access the boolean property on the default export. This is one of the cases where CJS does not map very well to ESM (though I must admit, boolean is probably only problematic in some old IE versions).

lukastaegert commented 5 years ago

This is also one of the reasons why in Node's ESM support, this will be the only way to import CJS modules into ESM modules.

vladshcherbin commented 5 years ago

@lukastaegert will use it this way then. There is also a bool export, probably an alias, an old api or smth. Thank you 🤗