Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

v4.1.0 doesn't respect modules: false anymore #203

Closed
cecilia-sanare opened this issue Apr 6, 2019 · 1 comment · Fixed by #204
Closed

v4.1.0 doesn't respect modules: false anymore #203

cecilia-sanare opened this issue Apr 6, 2019 · 1 comment · Fixed by #204

Comments

@cecilia-sanare
Copy link
Contributor

cecilia-sanare commented Apr 6, 2019

Description

👋 Hey there! Some of my libraries ended up catching a breaking change in this library.

The change to add the new mainFields option also made it so that module
is no longer take into account when determining what fields to pull.

Simple Example

const resolve = require('rollup-plugin-node-resolve');

module.exports = {
    // The rest of my rollup configuration ...

    plugins: [
        resolve({
            module: false, // still results in `mainFields` = ['main', 'module']
            browser: true,

            extensions: ['.mjs', '.js', '.jsx', '.json', '.ts']
        })

        // The rest of my super cool plugins ...
    ]
}

Related Code

mainFields = ['module', 'main'];
[['module', 'module'], ['jsnext', 'jsnext:main'], ['main', 'main']].forEach(([option, field]) => {
if (option in options) {
// eslint-disable-next-line no-console
console.warn(`node-resolve: setting options.${option} is deprecated, please override options.mainFields instead`);
if (options[option] === false) {
mainFields = mainFields.filter(mainField => mainField === field);
} else if (options[option] === true && mainFields.indexOf(field) === -1) {
mainFields.push(field);
}
}
});

Workaround

Just move to the new field since it works correctly.

@cecilia-sanare
Copy link
Contributor Author

cecilia-sanare commented Apr 6, 2019

After digging into it a little bit more, it looks like:

mainFields = mainFields.filter(mainField => mainField === field); 

should be this:

mainFields = mainFields.filter(mainField => mainField !== field); 

EDIT: I've opened a PR to resolve this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant