Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin not replacing all uses of global #22

Open
mohd-akram opened this issue Jan 25, 2019 · 1 comment
Open

Plugin not replacing all uses of global #22

mohd-akram opened this issue Jan 25, 2019 · 1 comment

Comments

@mohd-akram
Copy link

I've noticed some instances of global are not replaced for some reason. I'm not sure what specifically is causing this but it happens with the node-fetch (2.3.0) library, for example:

rollup.config.js:

import globals from 'rollup-plugin-node-globals';
import resolve from 'rollup-plugin-node-resolve';

export default {
  output: {
    format: 'iife'
  },
  plugins: [
    resolve(),
    globals()
  ]
}

input.js:

import * as fetch from 'node-fetch';
console.log(fetch);

To test:

rollup -c -i input.js --silent | grep global

The output contains two instances of global:

Body.Promise = global.Promise;
fetch.Promise = global.Promise;
@mohd-akram
Copy link
Author

Found the issue - it's not checking .mjs files. This patch fixes it:

-if (id.slice(-3) !== '.js') return null;
+if (!['.js', '.mjs'].includes(path.extname(id))) return null;

afitzek added a commit to afitzek/rollup-plugin-node-globals that referenced this issue Jul 1, 2024
See: calvinmetcalf#22

Change-type: patch
Signed-off-by: Andreas Fitzek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant