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

default export of plugin-node-resolve does not work when using untranspiled (*.mjs) rollup config #412

Closed
arlac77 opened this issue May 24, 2020 · 7 comments

Comments

@arlac77
Copy link

arlac77 commented May 24, 2020

  • Rollup Plugin Name: @rollup/plugin-node-resolve
  • Rollup Plugin Version: 8.0.0 (7.x was working)
  • Rollup Version: 2.10.8
  • Operating System (or Browser): Darwin
  • Node Version: 14.3.0

How Do We Reproduce?

rollup -c rollup.config.mjs # use node native esm
import resolve from "@rollup/plugin-node-resolve";

export default {
    plugins: [resolve()]
};

plugin-node-resolve-from-native-esm

Expected Behavior

default export to be the resolve function

Actual Behavior

rollup -c rollup.config.mjs
[!] TypeError: resolve is not a function

Actions output

@shellscape
Copy link
Collaborator

Pull requests for Node 14+ ES Module issues are welcome. Node 14+ ES Module issues that are open for more than 30 days without an accompanying PR will be closed as abandoned.

TrySound added a commit that referenced this issue May 25, 2020
Ref #412

Wrapper module is the simplest solution. I used it in terser plugin
which cannot resolve worker without commonjs for now.
TrySound added a commit that referenced this issue May 26, 2020
Ref #412 #413

Enable native node es modules via "exports" field in package.json.
Added custom plugin to generate nested package.json with `{"type": "module"}`
to prevent mjs extension usage.
brettz9 added a commit to brettz9/JSON6 that referenced this issue May 28, 2020
@brettz9
Copy link

brettz9 commented May 28, 2020

In case it is the same issue, I'm seeing this error on Node 10 (though with a file being exported to have an mjs extension rather than the Rollup config itself using mjs)

shellscape pushed a commit that referenced this issue Jun 1, 2020
* feat(pluginutils): add native node es modules support

Ref #412 #413

Enable native node es modules via "exports" field in package.json.
Added custom plugin to generate nested package.json with `{"type": "module"}`
to prevent mjs extension usage.

* Export emitModulePackageFile from shared config

* Bundle estree-walker

* Swap options
TrySound added a commit that referenced this issue Jun 1, 2020
Ref #412

Enable native node es modules via "exports" field in package.json.
Added custom plugin to generate nested package.json with {"type": "module"}
as an alternative to mjs extension usage. This works similar to rollup distribution.
https://unpkg.com/browse/[email protected]/dist/es/
shellscape pushed a commit that referenced this issue Jun 7, 2020
Ref #412

Enable native node es modules via "exports" field in package.json.
Added custom plugin to generate nested package.json with {"type": "module"}
as an alternative to mjs extension usage. This works similar to rollup distribution.
https://unpkg.com/browse/[email protected]/dist/es/
@jrgleason
Copy link

Is there a work around for this? I am hitting it too

@shellscape
Copy link
Collaborator

@jrgleason if there was, you'd likely see it here in the comments. We welcome contributions for these types of issues.

@arlac77
Copy link
Author

arlac77 commented Jun 8, 2020

@jrgleason

try resolve.nodeResolve()

import resolve from "@rollup/plugin-node-resolve";

export default {
plugins: [
    resolve.nodeResolve()
]
}

@jrgleason
Copy link

@arlac77 Thanks that looks like it worked

heavyk added a commit to heavyk/plugins that referenced this issue Jun 15, 2020
@arlac77
Copy link
Author

arlac77 commented Jun 23, 2020

@rollup/[email protected] has fixed the problem
Thanks

@arlac77 arlac77 closed this as completed Jun 23, 2020
LarsDenBakker pushed a commit to LarsDenBakker/plugins that referenced this issue Sep 12, 2020
* feat(pluginutils): add native node es modules support

Ref rollup#412 rollup#413

Enable native node es modules via "exports" field in package.json.
Added custom plugin to generate nested package.json with `{"type": "module"}`
to prevent mjs extension usage.

* Export emitModulePackageFile from shared config

* Bundle estree-walker

* Swap options
LarsDenBakker pushed a commit to LarsDenBakker/plugins that referenced this issue Sep 12, 2020
Ref rollup#412

Enable native node es modules via "exports" field in package.json.
Added custom plugin to generate nested package.json with {"type": "module"}
as an alternative to mjs extension usage. This works similar to rollup distribution.
https://unpkg.com/browse/[email protected]/dist/es/
LarsDenBakker pushed a commit to LarsDenBakker/plugins that referenced this issue Sep 12, 2020
vasttiankliu pushed a commit to vasttiankliu/plugins that referenced this issue Nov 17, 2022
* feat(pluginutils): add native node es modules support

Ref rollup/plugins#412 rollup/plugins#413

Enable native node es modules via "exports" field in package.json.
Added custom plugin to generate nested package.json with `{"type": "module"}`
to prevent mjs extension usage.

* Export emitModulePackageFile from shared config

* Bundle estree-walker

* Swap options
vasttiankliu pushed a commit to vasttiankliu/plugins that referenced this issue Nov 17, 2022
Ref rollup/plugins#412

Enable native node es modules via "exports" field in package.json.
Added custom plugin to generate nested package.json with {"type": "module"}
as an alternative to mjs extension usage. This works similar to rollup distribution.
https://unpkg.com/browse/[email protected]/dist/es/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants