-
-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(node-resolve): add rootDir option (#98)
* feat(node-resolve): add rootDir option * chore: update .eslintignore for new fixtures * test: add missing snapshots * Update packages/node-resolve/README.md Co-Authored-By: Tiger Oakes <[email protected]> * test(node-resolve): remove test.only Co-authored-by: Andrew Powell <[email protected]> Co-authored-by: Tiger Oakes <[email protected]>
- Loading branch information
1 parent
94875f0
commit df6835e
Showing
12 changed files
with
77 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
test/fixtures/node_modules | ||
test/fixtures/**/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/node-resolve/test/fixtures/monorepo-dedupe/node_modules/react/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
packages/node-resolve/test/fixtures/monorepo-dedupe/packages/package-a/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from 'react'; | ||
|
||
import packageB from '../package-b/index.js'; | ||
|
||
export default `Package A React: ${React} | ${packageB}`; |
1 change: 1 addition & 0 deletions
1
...node-resolve/test/fixtures/monorepo-dedupe/packages/package-a/node_modules/react/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
packages/node-resolve/test/fixtures/monorepo-dedupe/packages/package-b/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import React from 'react'; | ||
|
||
export default `package B react: ${React}`; |
1 change: 1 addition & 0 deletions
1
...node-resolve/test/fixtures/monorepo-dedupe/packages/package-b/node_modules/react/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const { join } = require('path'); | ||
|
||
const test = require('ava'); | ||
const { rollup } = require('rollup'); | ||
|
||
const { testBundle } = require('../../../util/test'); | ||
|
||
const nodeResolve = require('..'); | ||
|
||
process.chdir(join(__dirname, 'fixtures', 'monorepo-dedupe', 'packages', 'package-a')); | ||
|
||
test('deduplicates modules from the given root directory', async (t) => { | ||
const bundle = await rollup({ | ||
input: 'index.js', | ||
plugins: [ | ||
nodeResolve({ | ||
dedupe: ['react'], | ||
rootDir: join(__dirname, 'fixtures', 'monorepo-dedupe') | ||
}) | ||
] | ||
}); | ||
const { module } = await testBundle(t, bundle); | ||
|
||
t.snapshot(module.exports); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Snapshot report for `test/root-dir.js` | ||
|
||
The actual snapshot is saved in `root-dir.js.snap`. | ||
|
||
Generated by [AVA](https://ava.li). | ||
|
||
## deduplicated from the given root directory | ||
|
||
> Snapshot 1 | ||
'Package A React: react imported from root | package B react: react imported from root' | ||
|
||
## deduplicates modules from the given root directory | ||
|
||
> Snapshot 1 | ||
'Package A React: react imported from root | package B react: react imported from root' |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters