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

Named Exports Edge Case #279

Closed Undistraction closed 6 years ago

Undistraction commented 6 years ago

I've been using folktale with the following config:

commonjs({
  namedExports: {
    node_modules/folktale/index.js': [`validation`],
  },
}),

To get round the error:

Error: 'Failure' is not exported by node_modules/folktale/validation/index.js

This lets me do:

import { validation as Validation } from 'folktale';
const { Success, Failure } = Validation;

So far so good, but I now need to use collect from the same package. The problem is that collect is exported differently from Success and Failure and triggers the same warning.

import { validation as Validation } from 'folktale';
const { Success, Failure, collect } = Validation;

Gives me:

> Error: 'collect' is not exported by node_modules/folktale/validation/index.js

Here are the exports from node_modules/folktale/validation/index.js

module.exports = (_module$exports = {
  Success: Validation.Success,
  Failure: Validation.Failure,
  hasInstance: Validation.hasInstance,
  of: Validation.of,
  fromJSON: Validation.fromJSON
}, _defineProperty(_module$exports, typeSymbol, Validation[typeSymbol]), _defineProperty(_module$exports, 'collect', require('./collect')), _defineProperty(_module$exports, 'fromNullable', function fromNullable(aNullable, fallbackValue) {
  return require('../conversions/nullable-to-validation')(aNullable, fallbackValue);
}), _defineProperty(_module$exports, 'fromResult', function fromResult(aResult) {
  return require('../conversions/result-to-validation')(aResult);
}), _defineProperty(_module$exports, 'fromMaybe', function fromMaybe(aMaybe, fallbackValue) {
  return require('../conversions/maybe-to-validation')(aMaybe, fallbackValue);
}), _module$exports);

It doesn't look like there is a way to work around this.

Folktale main index and validation index

rollup@0.54.0 node@9.3.0

Undistraction commented 6 years ago

That's what happens when you use auto-import in VSCode. :(