-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
feat(node-resolve): Export defaults #301
feat(node-resolve): Export defaults #301
Conversation
2e86cf2
to
8aa6196
Compare
Hey thanks for the PR! Looks like that broke a few things. Give that a test run locally. |
Hmmm tests are failing because I'm doing an export default and a named export now. @shellscape Any idea on how to make this a non-breaking change? 🤔 |
We might need some wrapper for the common JS output. Before: module.exports = nodeResolve(...) After: exports.default = nodeResolve(...)
exports.defaults = defaults Ideal: mod = nodeResolve(...)
mod.defaults = defaults
module.exports = mod Also, since |
@NotWoods Wrapping the module still fails tests |
@MichaelDeBoey please merge from master again. we fixed up some CI related things today. |
5ccffec
to
284d037
Compare
@shellscape Rebased, but CI is still failing tho 😕 |
Bummer. Next step is to run tests locally to triage from there: |
@shellscape It's still the same error TypeError {
message: 'nodeResolve is not a function',
} This is because the plugin now exports both a default and a named export. So I don't think we can do this without a breaking change/major release. 🤔 |
The wrapper should be extracted to a separate file, and used as the entry point for only the CJS build. The presence of an |
@NotWoods Could you point me in the right direction on how I could best fix this? 🤔 |
This behavior might be better inside an output plugin, but here's something I whipped together: // cjs-wrapper.js
import nodeResolve, { DEFAULT_OPTIONS } from './index';
nodeResolve.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
export default nodeResolve; // rollup.config.js
import babel from 'rollup-plugin-babel';
import json from '@rollup/plugin-json';
import pkg from './package.json';
const plugins = [
json(),
babel({
presets: [
[
'@babel/preset-env',
{
targets: {
node: 6
}
}
]
]
})
];
const external = Object.keys(pkg.dependencies).concat(['fs', 'path', 'os', 'util']);
export default [
{
input: 'src/index.js',
plugins,
external,
output: [
{ file: pkg.module, format: 'es' }
]
},
{
input: 'src/cjs-wrapper.js',
plugins,
external,
output: [
{ file: pkg.main, format: 'cjs' }
]
},
]; |
@shellscape @NotWoods All is green now 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working through the issues getting CI good and a solid wrapper going. Now that we've got a good approach, I've got a few points I wanted to touch on. Please don't get discouraged!
5e32561
to
3cd8ce3
Compare
@shellscape @NotWoods All is green again now 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for continuing to work through this. I'm sorry for the delayed reviews, doing the best I can with the time I've got on my end.
853111a
to
53d46c0
Compare
bb1bf0a
to
f983f7c
Compare
@MichaelDeBoey I'll fix this conflict when I get the chance to circle back. |
f983f7c
to
b27916e
Compare
@shellscape Rebase onto |
Thanks for all the hard work that went into this one. |
With pleasure! 🙂 |
BREAKING CHANGE: The plugin function is no longer the default export. Moving forward, there are two named exports: ```js { DEFAULTS, nodeResolve } ``` * feat(node-resolve): Export defaults * Wrap module * Don't export DEFAULT_OPTIONS directly * Create cjs-wrapper * Named export * Freeze defaults * Deep freeze defaults * Deep merge defaults
Rollup Plugin Name:
node-resolve
This PR contains:
Are tests included?
Breaking Changes?
If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.
Note from @shellscape: We're going to change this to a named export and will break. Needs a new major.
List any relevant issue numbers:
Description
Closes #299