-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
* Use inputFS.realpathSync get realpath of module * Add test for symlink structure * add symlink file * dynamically create symlinks for test * Update packages/utils/node-resolver-core/src/NodeResolver.js Co-authored-by: Amin Yahyaabadi <[email protected]> * Update NodeResolver.js * Update packages/utils/node-resolver-core/src/NodeResolver.js Co-authored-by: Amin Yahyaabadi <[email protected]> * Update packages/utils/node-resolver-core/src/NodeResolver.js Co-authored-by: Amin Yahyaabadi <[email protected]> * use realpath * Tests use overlayFS * Update packages/utils/node-resolver-core/src/NodeResolver.js Co-authored-by: Amin Yahyaabadi <[email protected]> * Realpath at the end of resolution * Remove realpaths that are now unnecessary * Fix sourcemaps tests * Add tests for symlink resolution * Remove realpath comment * prettier Co-authored-by: dishuostec <[email protected]> Co-authored-by: Niklas Mischkulnig <[email protected]> Co-authored-by: Jasper De Moor <[email protected]> Co-authored-by: Amin Yahyaabadi <[email protected]> Co-authored-by: dishuostec <[email protected]> Co-authored-by: Will Binns-Smith <[email protected]>
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import count from 'pkg'; | ||
import init from 'library'; | ||
|
||
init(); | ||
export default count(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"private": true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "library", | ||
"main": "src/index.js", | ||
"private": true | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import count from 'pkg'; | ||
|
||
export default function init() { | ||
count(); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
packages: | ||
# all packages in subdirs of packages/ | ||
- 'packages/*' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import {answer} from 'library'; | ||
|
||
export default answer; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"private": true | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import assert from 'assert'; | ||
import path from 'path'; | ||
import {bundle, run} from '@parcel/test-utils'; | ||
import {bundle, run, ncp, overlayFS, outputFS} from '@parcel/test-utils'; | ||
|
||
describe('resolver', function() { | ||
it('should support resolving tilde in monorepo packages', async function() { | ||
|
@@ -256,4 +256,83 @@ describe('resolver', function() { | |
let output = await run(b); | ||
assert.deepEqual(output.default, {}); | ||
}); | ||
|
||
it('should support symlinked node_modules structure', async function() { | ||
const rootDir = path.join( | ||
__dirname, | ||
'integration/resolve-symlinked-node_modules-structure', | ||
); | ||
|
||
await overlayFS.mkdirp(rootDir); | ||
await ncp(rootDir, rootDir); | ||
|
||
await outputFS.symlink( | ||
path.join( | ||
rootDir, | ||
'node_modules/.origin/[email protected]/node_modules/library', | ||
), | ||
path.join(rootDir, 'node_modules/library'), | ||
); | ||
await outputFS.symlink( | ||
path.join( | ||
rootDir, | ||
'node_modules/.origin/[email protected]/node_modules/library-dep', | ||
), | ||
path.join( | ||
rootDir, | ||
'node_modules/.origin/[email protected]/node_modules/library-dep', | ||
), | ||
); | ||
|
||
let b = await bundle( | ||
path.join( | ||
__dirname, | ||
'/integration/resolve-symlinked-node_modules-structure/index.js', | ||
), | ||
{ | ||
inputFS: overlayFS, | ||
outputFS, | ||
}, | ||
); | ||
|
||
let output = await run(b); | ||
assert.strictEqual(output.default, 42); | ||
}); | ||
|
||
it('should support symlinked monorepos structure', async function() { | ||
const rootDir = path.join( | ||
__dirname, | ||
'integration/resolve-symlinked-monorepos', | ||
); | ||
|
||
await overlayFS.mkdirp(rootDir); | ||
await ncp(rootDir, rootDir); | ||
|
||
await outputFS.symlink( | ||
path.join(rootDir, 'packages/library'), | ||
path.join(rootDir, 'packages/app/node_modules/library'), | ||
); | ||
await outputFS.symlink( | ||
path.join(rootDir, 'node_modules/.origin/[email protected]/node_modules/pkg'), | ||
path.join(rootDir, 'packages/app/node_modules/pkg'), | ||
); | ||
await outputFS.symlink( | ||
path.join(rootDir, 'node_modules/.origin/[email protected]/node_modules/pkg'), | ||
path.join(rootDir, 'packages/library/node_modules/pkg'), | ||
); | ||
|
||
let b = await bundle( | ||
path.join( | ||
__dirname, | ||
'/integration/resolve-symlinked-monorepos/packages/app/index.js', | ||
), | ||
{ | ||
inputFS: overlayFS, | ||
outputFS, | ||
}, | ||
); | ||
|
||
let output = await run(b); | ||
assert.strictEqual(output.default, 2); | ||
}); | ||
}); |