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

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rollup/rollup-plugin-node-resolve
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7846a19da76e84f81f349162e6cf281550f6a67d
Choose a base ref
...
head repository: rollup/rollup-plugin-node-resolve
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 07b00d0bc9a59951ce1ff0548cb7fa9d92531d22
Choose a head ref
Loading
Showing with 3,524 additions and 1,267 deletions.
  1. +1 −1 .eslintrc
  2. +48 −0 .github/ISSUE_TEMPLATE/BUG.md
  3. +33 −0 .github/ISSUE_TEMPLATE/DOCS.md
  4. +24 −0 .github/ISSUE_TEMPLATE/FEATURE.md
  5. +28 −0 .github/ISSUE_TEMPLATE/MODIFICATION.md
  6. +13 −0 .github/ISSUE_TEMPLATE/SUPPORT.md
  7. +1 −0 .gitignore
  8. +6 −2 .travis.yml
  9. +104 −0 CHANGELOG.md
  10. +43 −10 README.md
  11. +100 −0 index.d.ts
  12. +2,123 −996 package-lock.json
  13. +22 −13 package.json
  14. +14 −3 rollup.config.js
  15. +0 −1 src/empty.js
  16. +283 −130 src/index.js
  17. +1 −1 test/mocha.opts
  18. +2 −0 test/node_modules/browser-entry-points-to-node-module/index.js
  19. +6 −0 test/node_modules/browser-entry-points-to-node-module/package.json
  20. +1 −0 test/node_modules/component-type/index.js
  21. +3 −0 test/node_modules/component-type/package.json
  22. +1 −0 test/node_modules/dual-cjs-mjs/entry.js
  23. +1 −0 test/node_modules/dual-cjs-mjs/entry.mjs
  24. +3 −0 test/node_modules/dual-cjs-mjs/package.json
  25. +1 −1 test/node_modules/isomorphic-nested/lib/browser.js
  26. +1 −1 test/node_modules/isomorphic-nested/lib/index.js
  27. +1 −1 test/node_modules/isomorphic-object-main-implicit/browser.js
  28. +1 −1 test/node_modules/isomorphic-object-main-implicit/index.js
  29. +1 −1 test/node_modules/isomorphic-object-main/browser.js
  30. +1 −1 test/node_modules/isomorphic-object-main/index.js
  31. +4 −0 test/node_modules/isomorphic-object-with-false/lib/client/http-tracker.js
  32. +4 −0 test/node_modules/isomorphic-object-with-false/lib/client/udp-tracker.js
  33. +4 −0 test/node_modules/isomorphic-object-with-false/lib/client/websocket-tracker.js
  34. +20 −0 test/node_modules/isomorphic-object-with-false/lib/index.js
  35. +2 −0 test/node_modules/isomorphic-object-with-false/lib/subpath/foo/index.js
  36. +8 −0 test/node_modules/isomorphic-object-with-false/package.json
  37. +1 −1 test/node_modules/isomorphic-object/browser.js
  38. +1 −1 test/node_modules/isomorphic-object/index.js
  39. +1 −0 test/node_modules/jsnext/entry-main.js
  40. +2 −1 test/node_modules/jsnext/package.json
  41. +1 −0 test/node_modules/module-mjs/entry.mjs
  42. +3 −0 test/node_modules/module-mjs/package.json
  43. +1 −0 test/node_modules/module/entry-main.js
  44. +1 −0 test/node_modules/module/package.json
  45. +3 −0 test/node_modules/react-consumer/index.js
  46. 0 test/node_modules/react-consumer/node_modules/.gitkeep
  47. +1 −0 test/node_modules/react-consumer/node_modules/react/index.js
  48. +1 −0 test/node_modules/react/index.js
  49. +4 −0 test/node_modules/side-effects-array/dep1.js
  50. +4 −0 test/node_modules/side-effects-array/dep2.js
  51. +4 −0 test/node_modules/side-effects-array/dep3-effect.js
  52. +8 −0 test/node_modules/side-effects-array/index.js
  53. +4 −0 test/node_modules/side-effects-array/nested/dep4.js
  54. +4 −0 test/node_modules/side-effects-array/nested/dep5-effect.js
  55. +8 −0 test/node_modules/side-effects-array/package.json
  56. +4 −0 test/node_modules/side-effects-false/dep1.js
  57. +4 −0 test/node_modules/side-effects-false/dep2.js
  58. +5 −0 test/node_modules/side-effects-false/index.js
  59. +4 −0 test/node_modules/side-effects-false/package.json
  60. +4 −0 test/node_modules/side-effects-true/dep1.js
  61. +4 −0 test/node_modules/side-effects-true/dep2.js
  62. +5 −0 test/node_modules/side-effects-true/index.js
  63. +4 −0 test/node_modules/side-effects-true/package.json
  64. +1 −0 test/node_modules/simple/index.js
  65. +15 −0 test/package.json
  66. +2 −0 test/samples/browser-entry-points-to-node-module/index.js
  67. +4 −0 test/samples/browser-local/main.js
  68. +15 −0 test/samples/browser-object-with-false/main.js
  69. +3 −0 test/samples/dual-cjs-mjs/main.js
  70. +1 −0 test/samples/dynamic/main.js
  71. +2 −2 test/samples/jsnext/main.js
  72. +3 −0 test/samples/manualchunks/main.js
  73. +3 −0 test/samples/module-mjs/main.js
  74. +3 −0 test/samples/prefer-main/main.js
  75. +4 −0 test/samples/react-app/main.js
  76. +3 −0 test/samples/side-effects/main.js
  77. +422 −99 test/test.js
  78. +16 −0 tsconfig.json
  79. +32 −0 typings-test.js
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"rules": {
"indent": [ 2, "tab", { "SwitchCase": 1 } ],
"quotes": [ 2, "single", { allowTemplateLiterals: true } ],
"quotes": [ 2, "single", { "allowTemplateLiterals": true } ],
"semi": [ 2, "always" ],
"keyword-spacing": [ 2, { "before": true, "after": true } ],
"space-before-blocks": [ 2, "always" ],
48 changes: 48 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
name: 🐞 Bug Report
about: Something went awry and you'd like to tell us about it.

---

<!--
⚡️ katchow! We 💛 issues.
Please - do not - remove this template.
Please - do not - skip or remove parts of this template.
Or your issue may be closed.
👉🏽 Need help or tech support? Please don't open an issue!
Head to https://gitter.im/rollup/rollup or https://stackoverflow.com/questions/tagged/rollupjs
❤️ Rollup? Please consider supporting our collective:
👉 https://opencollective.com/rollup/donate
-->

- Node-Resolve Plugin Version:
- Rollup Version:
- Operating System (or Browser):
- Node Version:

### How Do We Reproduce?

<!--
Issues without minimal reproductions will be closed! Please provide one by:
1. Work to isolate the problem and provide the exact steps in this issue, or
2. Provide a minimal repository link (Read https://git.io/fNzHA for instructions).
These may take more time to triage than the other options.
-->


### Expected Behavior


### Actual Behavior


<!--
Most issues can be expressed or demonstrated through a reproduction repository.
However, the situation may arise where some small code snippets also need to
be provided. In that situation, please add your code below using
Fenced Code Blocks (https://help.github.com/articles/creating-and-highlighting-code-blocks/)
-->

33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/DOCS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: 📚 Documentation
about: Are the docs lacking or missing something? Do they need some new 🔥 hotness? Tell us here.

---

<!--
⚡️ katchow! We 💛 issues.
Please - do not - remove this template.
Please - do not - skip or remove parts of this template.
Or your issue may be closed.
👉🏽 Need help or tech support? Don't open an issue!
Head to https://gitter.im/rollup/rollup or https://stackoverflow.com/questions/tagged/rollupjs
❤️ Rollup? Please consider supporting our collective:
👉 https://opencollective.com/rollup/donate
-->

Documentation Is:

<!-- Please place an x (no spaces!) in all [ ] that apply -->

- [ ] Missing
- [ ] Needed
- [ ] Confusing
- [ ] Not Sure?

### Please Explain in Detail...


### Your Proposal for Changes
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: ✨ Feature Request
about: Suggest an idea for this project

---

<!--
⚡️ katchow! We 💛 issues.
Please - do not - remove this template.
Please - do not - skip or remove parts of this template.
Or your issue may be closed.
👉🏽 Need help or tech support? Please don't open an issue!
Head to https://gitter.im/rollup/rollup or https://stackoverflow.com/questions/tagged/rollupjs
❤️ Rollup? Please consider supporting our collective:
👉 https://opencollective.com/rollup/donate
-->

### Feature Use Case


### Feature Proposal
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/MODIFICATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: 🔧 Modification Request
about: Would you like something work differently? Have an alternative approach? This is the template for you.

---

<!--
⚡️ katchow! We 💛 issues.
Please - do not - remove this template.
Please - do not - skip or remove parts of this template.
Or your issue may be closed.
👉🏽 Need help or tech support? Please don't open an issue!
Head to https://gitter.im/rollup/rollup or https://stackoverflow.com/questions/tagged/rollupjs
❤️ Rollup? Please consider supporting our collective:
👉 https://opencollective.com/rollup/donate
-->


### Expected Behavior / Situation


### Actual Behavior / Situation


### Modification Proposal
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/SUPPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: 🆘 Support, Help, and Advice
about: 👉🏽 Need help or tech support? Please don't open an issue! Head to https://gitter.im/rollup/rollup or https://stackoverflow.com/questions/tagged/rollupjs.

---

Hey there! If you need help or tech support then this is not the place to
ask. Please head to [the Rollup Gitter](https://gitter.im/rollup/rollup)
instead or post a question to https://stackoverflow.com/questions/tagged/rollupjs.

If you arrived here because you think Rollup's documentation is unclear,
insufficient or wrong, please consider creating an issue for the documentation
instead.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -3,3 +3,4 @@ node_modules
dist
.gobble*
!test/node_modules
!test/node_modules/react-consumer/node_modules
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
language: node_js
node_js:
- "4"
- "6"
- "stable"
- "8"
- "10"
- "12"
env:
global:
- BUILD_TIMEOUT=10000
install: npm ci --ignore-scripts
before_install:
- if [[ $TRAVIS_NODE_VERSION -lt 8 ]]; then npm install --global npm@5; fi
104 changes: 104 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,109 @@
# rollup-plugin-node-resolve changelog

## 5.2.0 (2019-06-29)

* dedupe accepts a function ([#225](https://github.com/rollup/rollup-plugin-node-resolve/pull/225) by @manucorporat)

## 5.1.1 (2019-06-29)

* Move Rollup version check to buildStart hook to avoid issues ([#232](https://github.com/rollup/rollup-plugin-node-resolve/pull/232) by @lukastaegert)

## 5.1.0 (2019-06-22)

* Fix path fragment inputs ([#229](https://github.com/rollup/rollup-plugin-node-resolve/pull/229) by @bterlson)

## 5.0.4 (2019-06-22)

* Treat sideEffects array as inclusion list ([#227](https://github.com/rollup/rollup-plugin-node-resolve/pull/227) by @mikeharder)

## 5.0.3 (2019-06-16)

* Make empty.js a virtual module ([#224](https://github.com/rollup/rollup-plugin-node-resolve/pull/224) by @manucorporat)

## 5.0.2 (2019-06-13)

* Support resolve 1.11.1, add built-in test ([#223](https://github.com/rollup/rollup-plugin-node-resolve/pull/223) by @bterlson)

## 5.0.1 (2019-05-31)

* Update to resolve@1.11.0 for better performance ([#220](https://github.com/rollup/rollup-plugin-node-resolve/pull/220) by @keithamus)

## 5.0.0 (2019-05-15)

* Replace bublé with babel, update dependencies ([#216](https://github.com/rollup/rollup-plugin-node-resolve/pull/216) by @mecurc)
* Handle module side-effects ([#219](https://github.com/rollup/rollup-plugin-node-resolve/pull/219) by @lukastaegert)

### Breaking Changes

* Requires at least rollup@1.11.0 to work (v1.12.0 for module side-effects to be respected)
* If used with rollup-plugin-commonjs, it should be at least v10.0.0

## 4.2.4 (2019-05-11)

* Add note on builtins to Readme ([#215](https://github.com/rollup/rollup-plugin-node-resolve/pull/215) by @keithamus)
* Add issue templates ([#217](https://github.com/rollup/rollup-plugin-node-resolve/pull/217) by @mecurc)
* Improve performance by caching `isDir` ([#218](https://github.com/rollup/rollup-plugin-node-resolve/pull/218) by @keithamus)

## 4.2.3 (2019-04-11)

* Fix ordering of jsnext:main when using the jsnext option ([#209](https://github.com/rollup/rollup-plugin-node-resolve/pull/209) by @lukastaegert)

## 4.2.2 (2019-04-10)

* Fix TypeScript typings (rename and export Options interface) ([#206](https://github.com/rollup/rollup-plugin-node-resolve/pull/206) by @Kocal)
* Fix mainfields typing ([#207](https://github.com/rollup/rollup-plugin-node-resolve/pull/207) by @nicolashenry)

## 4.2.1 (2019-04-06)

* Respect setting the deprecated fields "module", "main", and "jsnext" ([#204](https://github.com/rollup/rollup-plugin-node-resolve/pull/204) by @nick-woodward)

## 4.2.0 (2019-04-06)

* Add new mainfields option ([#182](https://github.com/rollup/rollup-plugin-node-resolve/pull/182) by @keithamus)
* Added dedupe option to prevent bundling the same package multiple times ([#201](https://github.com/rollup/rollup-plugin-node-resolve/pull/182) by @sormy)

## 4.1.0 (2019-04-05)

* Add TypeScript typings ([#189](https://github.com/rollup/rollup-plugin-node-resolve/pull/189) by @NotWoods)
* Update dependencies ([#202](https://github.com/rollup/rollup-plugin-node-resolve/pull/202) by @lukastaegert)

## 4.0.1 (2019-02-22)

* Fix issue when external modules are specified in `package.browser` ([#143](https://github.com/rollup/rollup-plugin-node-resolve/pull/143) by @keithamus)
* Fix `package.browser` mapping issue when `false` is specified ([#183](https://github.com/rollup/rollup-plugin-node-resolve/pull/183) by @allex)

## 4.0.0 (2018-12-09)

This release will support rollup@1.0

### Features
* Resolve modules used to define manual chunks ([#185](https://github.com/rollup/rollup-plugin-node-resolve/pull/185) by @mcshaman)
* Update dependencies and plugin hook usage ([#187](https://github.com/rollup/rollup-plugin-node-resolve/pull/187) by @lukastaegert)

## 3.4.0 (2018-09-04)

This release now supports `.mjs` files by default

### Features
* feat: Support .mjs files by default (https://github.com/rollup/rollup-plugin-node-resolve/pull/151, by @leebyron)

## 3.3.0 (2018-03-17)

This release adds the `only` option

### New Features
* feat: add `only` option (#83; @arantes555)

### Docs
* docs: correct description of `jail` option (#120; @GeorgeTaveras1231)

## 3.2.0 (2018-03-07)

This release caches reading/statting of files, to improve speed.

### Performance Improvements
* perf: cache file stats/reads (#126; @keithamus)

## 3.0.4 (unreleased)

* Update lockfile [#137](https://github.com/rollup/rollup-plugin-node-resolve/issues/137)
53 changes: 43 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -20,31 +20,42 @@ export default {
input: 'main.js',
output: {
file: 'bundle.js',
format: 'iife'
format: 'iife',
name: 'MyModule'
},
name: 'MyModule',
plugins: [
resolve({

// the fields to scan in a package.json to determine the entry point
// if this list contains "browser", overrides specified in "pkg.browser"
// will be used
mainFields: ['module', 'main'], // Default: ['module', 'main']

// DEPRECATED: use "mainFields" instead
// use "module" field for ES6 module if possible
module: true, // Default: true

// DEPRECATED: use "mainFields" instead
// use "jsnext:main" if possible
// – see https://github.com/rollup/rollup/wiki/jsnext:main
// legacy field pointing to ES6 module in third-party libraries,
// deprecated in favor of "pkg.module":
// - see: https://github.com/rollup/rollup/wiki/pkg.module
jsnext: true, // Default: false

// DEPRECATED: use "mainFields" instead
// use "main" field or index.js, even if it's not an ES6 module
// (needs to be converted from CommonJS to ES6
// (needs to be converted from CommonJS to ES6)
// – see https://github.com/rollup/rollup-plugin-commonjs
main: true, // Default: true

// some package.json files have a `browser` field which
// specifies alternative files to load for people bundling
// for the browser. If that's you, use this option, otherwise
// pkg.browser will be ignored
// some package.json files have a "browser" field which specifies
// alternative files to load for people bundling for the browser. If
// that's you, either use this option or add "browser" to the
// "mainfields" option, otherwise pkg.browser will be ignored
browser: true, // Default: false

// not all files you want to resolve are .js files
extensions: [ '.js', '.json' ], // Default: ['.js']
extensions: [ '.mjs', '.js', '.jsx', '.json' ], // Default: [ '.mjs', '.js', '.json', '.node' ]

// whether to prefer built-in modules (e.g. `fs`, `path`) or
// local ones with the same names
@@ -53,7 +64,7 @@ export default {
// Lock the module search in this path (like a chroot). Module defined
// outside this path will be marked as external
jail: '/my/jail/path', // Default: '/'

// Set to an array of strings and/or regexps to lock the module search
// to modules that match at least one entry. Modules not matching any
// entry will be marked as external
@@ -63,6 +74,11 @@ export default {
// ES2015 modules
modulesOnly: true, // Default: false

// Force resolving for these modules to root's node_modules that helps
// to prevent bundling the same package multiple times if package is
// imported from dependencies.
dedupe: [ 'react', 'react-dom' ], // Default: []

// Any additional options that should be passed through
// to node-resolve
customResolveOptions: {
@@ -96,6 +112,23 @@ export default {
};
```

## Resolving Built-Ins (like `fs`)

This plugin won't resolve any builtins (e.g. `fs`). If you need to resolve builtins you can install local modules and set `preferBuiltins` to `false`, or install a plugin like [rollup-plugin-node-builtins](https://github.com/calvinmetcalf/rollup-plugin-node-builtins) which provides stubbed versions of these methods.

If you want to silence warnings about builtins, you can add the list of builtins to the `externals` option; like so:

```js
import resolve from 'rollup-plugin-node-resolve';
import builtins from 'builtin-modules'
export default ({
input: ...,
plugins: [resolve()],
externals: builtins,
output: ...
})
```


## License

Loading