From 04506b8c9d804f4783622c6c5cebfc9a622ae641 Mon Sep 17 00:00:00 2001 From: dishuostec Date: Mon, 27 Jul 2020 16:18:49 +0800 Subject: [PATCH 01/17] Use inputFS.realpathSync get realpath of module --- packages/utils/node-resolver-core/src/NodeResolver.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/utils/node-resolver-core/src/NodeResolver.js b/packages/utils/node-resolver-core/src/NodeResolver.js index f8f37fa1f49..376387b5692 100644 --- a/packages/utils/node-resolver-core/src/NodeResolver.js +++ b/packages/utils/node-resolver-core/src/NodeResolver.js @@ -515,11 +515,12 @@ export default class NodeResolver { let moduleDir = path.join(dir, 'node_modules', moduleName); let stats = await this.options.inputFS.stat(moduleDir); if (stats.isDirectory()) { + const realModuleDir = this.options.inputFS.realpathSync(moduleDir); return { moduleName: moduleName, subPath: subPath, - moduleDir: moduleDir, - filePath: path.join(dir, 'node_modules', filename), + moduleDir: realModuleDir, + filePath: path.join(realModuleDir, subPath || ''), }; } } catch (err) { From 5b53c6ff55759386f1054ca261790662516ad550 Mon Sep 17 00:00:00 2001 From: dishuostec Date: Mon, 27 Jul 2020 18:05:56 +0800 Subject: [PATCH 02/17] Add test for symlink structure --- .../pkg@1.0.0/node_modules/pkg/package.json | 6 +++++ .../pkg@1.0.0/node_modules/pkg/src/index.js | 5 ++++ .../packages/app/index.js | 5 ++++ .../packages/app/package.json | 3 +++ .../packages/library/node_modules/pkg | 1 + .../packages/library/package.json | 5 ++++ .../packages/library/src/index.js | 5 ++++ .../pnpm-lock.yaml | 1 + .../pnpm-workspace.yaml | 3 +++ .../index.js | 3 +++ .../node_modules/library-dep/package.json | 6 +++++ .../node_modules/library-dep/src/index.js | 1 + .../node_modules/library/package.json | 6 +++++ .../node_modules/library/src/index.js | 3 +++ .../node_modules/library | 1 + .../package.json | 3 +++ .../pnpm-lock.yaml | 1 + .../core/integration-tests/test/resolver.js | 24 +++++++++++++++++++ 18 files changed, 82 insertions(+) create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/node_modules/.origin/pkg@1.0.0/node_modules/pkg/package.json create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/node_modules/.origin/pkg@1.0.0/node_modules/pkg/src/index.js create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/index.js create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/package.json create mode 120000 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/node_modules/pkg create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/package.json create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/src/index.js create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/pnpm-lock.yaml create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/pnpm-workspace.yaml create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/index.js create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library-dep@1.0.0/node_modules/library-dep/package.json create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library-dep@1.0.0/node_modules/library-dep/src/index.js create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library/package.json create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library/src/index.js create mode 120000 packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/library create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/package.json create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/pnpm-lock.yaml diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/node_modules/.origin/pkg@1.0.0/node_modules/pkg/package.json b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/node_modules/.origin/pkg@1.0.0/node_modules/pkg/package.json new file mode 100644 index 00000000000..c44b4fd76e2 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/node_modules/.origin/pkg@1.0.0/node_modules/pkg/package.json @@ -0,0 +1,6 @@ +{ + "name": "library-dep", + "main": "src/index.js", + "version": "1.0.0", + "private": true +} diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/node_modules/.origin/pkg@1.0.0/node_modules/pkg/src/index.js b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/node_modules/.origin/pkg@1.0.0/node_modules/pkg/src/index.js new file mode 100644 index 00000000000..a528e501a4c --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/node_modules/.origin/pkg@1.0.0/node_modules/pkg/src/index.js @@ -0,0 +1,5 @@ +let number = 0; + +export default function count() { + return ++number; +} \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/index.js b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/index.js new file mode 100644 index 00000000000..68fafd6ec74 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/index.js @@ -0,0 +1,5 @@ +import count from 'pkg'; +import init from 'library'; + +init(); +export default count(); \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/package.json b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/package.json new file mode 100644 index 00000000000..352055cdf83 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/package.json @@ -0,0 +1,3 @@ +{ + "private": true +} diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/node_modules/pkg b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/node_modules/pkg new file mode 120000 index 00000000000..19ba8c0f9e2 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/node_modules/pkg @@ -0,0 +1 @@ +../../../node_modules/.origin/pkg@1.0.0/node_modules/pkg \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/package.json b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/package.json new file mode 100644 index 00000000000..42f025d9d4d --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/package.json @@ -0,0 +1,5 @@ +{ + "name": "library", + "main": "src/index.js", + "private": true +} diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/src/index.js b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/src/index.js new file mode 100644 index 00000000000..902dc666810 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/src/index.js @@ -0,0 +1,5 @@ +import count from 'pkg'; + +export default function init() { + count(); +} \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/pnpm-lock.yaml b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/pnpm-lock.yaml new file mode 100644 index 00000000000..fbcb46deb60 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/pnpm-lock.yaml @@ -0,0 +1 @@ +# To create a fake projectRoot diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/pnpm-workspace.yaml b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/pnpm-workspace.yaml new file mode 100644 index 00000000000..0b484649720 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/pnpm-workspace.yaml @@ -0,0 +1,3 @@ +packages: + # all packages in subdirs of packages/ + - 'packages/*' diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/index.js b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/index.js new file mode 100644 index 00000000000..ca9e12eb242 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/index.js @@ -0,0 +1,3 @@ +import {answer} from 'library'; + +export default answer; diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library-dep@1.0.0/node_modules/library-dep/package.json b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library-dep@1.0.0/node_modules/library-dep/package.json new file mode 100644 index 00000000000..c44b4fd76e2 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library-dep@1.0.0/node_modules/library-dep/package.json @@ -0,0 +1,6 @@ +{ + "name": "library-dep", + "main": "src/index.js", + "version": "1.0.0", + "private": true +} diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library-dep@1.0.0/node_modules/library-dep/src/index.js b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library-dep@1.0.0/node_modules/library-dep/src/index.js new file mode 100644 index 00000000000..a4012bff06c --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library-dep@1.0.0/node_modules/library-dep/src/index.js @@ -0,0 +1 @@ +export default 42; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library/package.json b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library/package.json new file mode 100644 index 00000000000..c44b4fd76e2 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library/package.json @@ -0,0 +1,6 @@ +{ + "name": "library-dep", + "main": "src/index.js", + "version": "1.0.0", + "private": true +} diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library/src/index.js b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library/src/index.js new file mode 100644 index 00000000000..9b33bee2882 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library/src/index.js @@ -0,0 +1,3 @@ +import answer from 'library-dep'; + +export {answer}; \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/library b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/library new file mode 120000 index 00000000000..460190565ee --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/library @@ -0,0 +1 @@ +.origin/library@1.0.0/node_modules/library \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/package.json b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/package.json new file mode 100644 index 00000000000..352055cdf83 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/package.json @@ -0,0 +1,3 @@ +{ + "private": true +} diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/pnpm-lock.yaml b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/pnpm-lock.yaml new file mode 100644 index 00000000000..fbcb46deb60 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/pnpm-lock.yaml @@ -0,0 +1 @@ +# To create a fake projectRoot diff --git a/packages/core/integration-tests/test/resolver.js b/packages/core/integration-tests/test/resolver.js index a5c0e0620e8..d1fb4879b4b 100644 --- a/packages/core/integration-tests/test/resolver.js +++ b/packages/core/integration-tests/test/resolver.js @@ -256,4 +256,28 @@ describe('resolver', function() { let output = await run(b); assert.deepEqual(output.default, {}); }); + + it('should support symlinked node_modules structure', async function() { + let b = await bundle( + path.join( + __dirname, + '/integration/resolve-symlinked-node_modules-structure/index.js', + ), + ); + + let output = await run(b); + assert.strictEqual(output.default, 42); + }); + + it('should support symlinked monorepos structure', async function() { + let b = await bundle( + path.join( + __dirname, + '/integration/resolve-symlinked-monorepos/packages/app/index.js', + ), + ); + + let output = await run(b); + assert.strictEqual(output.default, 2); + }); }); From c7ca64217b64c0180f92431117e02c1bddf5263a Mon Sep 17 00:00:00 2001 From: dishuostec Date: Mon, 27 Jul 2020 19:21:43 +0800 Subject: [PATCH 03/17] add symlink file --- .../packages/app/node_modules/library | 1 + .../resolve-symlinked-monorepos/packages/app/node_modules/pkg | 1 + .../node_modules/.origin/library@1.0.0/node_modules/library-dep | 1 + 3 files changed, 3 insertions(+) create mode 120000 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/library create mode 120000 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/pkg create mode 120000 packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library-dep diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/library b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/library new file mode 120000 index 00000000000..494d3c39e3a --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/library @@ -0,0 +1 @@ +../../library \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/pkg b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/pkg new file mode 120000 index 00000000000..19ba8c0f9e2 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/pkg @@ -0,0 +1 @@ +../../../node_modules/.origin/pkg@1.0.0/node_modules/pkg \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library-dep b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library-dep new file mode 120000 index 00000000000..b5d4afb6ad6 --- /dev/null +++ b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library-dep @@ -0,0 +1 @@ +../../library-dep@1.0.0/node_modules/library-dep \ No newline at end of file From a370cbca02f1f56710a00989d87992203033a17f Mon Sep 17 00:00:00 2001 From: dishuostec Date: Mon, 27 Jul 2020 20:31:43 +0800 Subject: [PATCH 04/17] dynamically create symlinks for test --- .../packages/app/node_modules/.gitkeep | 0 .../packages/app/node_modules/library | 1 - .../packages/app/node_modules/pkg | 1 - .../packages/library/node_modules/.gitkeep | 0 .../packages/library/node_modules/pkg | 1 - .../library@1.0.0/node_modules/library-dep | 1 - .../node_modules/library | 1 - .../core/integration-tests/test/resolver.js | 52 +++++++++++++++++++ 8 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/.gitkeep delete mode 120000 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/library delete mode 120000 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/pkg create mode 100644 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/node_modules/.gitkeep delete mode 120000 packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/node_modules/pkg delete mode 120000 packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library-dep delete mode 120000 packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/library diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/.gitkeep b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/library b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/library deleted file mode 120000 index 494d3c39e3a..00000000000 --- a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/library +++ /dev/null @@ -1 +0,0 @@ -../../library \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/pkg b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/pkg deleted file mode 120000 index 19ba8c0f9e2..00000000000 --- a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/app/node_modules/pkg +++ /dev/null @@ -1 +0,0 @@ -../../../node_modules/.origin/pkg@1.0.0/node_modules/pkg \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/node_modules/.gitkeep b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/node_modules/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/node_modules/pkg b/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/node_modules/pkg deleted file mode 120000 index 19ba8c0f9e2..00000000000 --- a/packages/core/integration-tests/test/integration/resolve-symlinked-monorepos/packages/library/node_modules/pkg +++ /dev/null @@ -1 +0,0 @@ -../../../node_modules/.origin/pkg@1.0.0/node_modules/pkg \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library-dep b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library-dep deleted file mode 120000 index b5d4afb6ad6..00000000000 --- a/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/.origin/library@1.0.0/node_modules/library-dep +++ /dev/null @@ -1 +0,0 @@ -../../library-dep@1.0.0/node_modules/library-dep \ No newline at end of file diff --git a/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/library b/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/library deleted file mode 120000 index 460190565ee..00000000000 --- a/packages/core/integration-tests/test/integration/resolve-symlinked-node_modules-structure/node_modules/library +++ /dev/null @@ -1 +0,0 @@ -.origin/library@1.0.0/node_modules/library \ No newline at end of file diff --git a/packages/core/integration-tests/test/resolver.js b/packages/core/integration-tests/test/resolver.js index d1fb4879b4b..d27f8f455f5 100644 --- a/packages/core/integration-tests/test/resolver.js +++ b/packages/core/integration-tests/test/resolver.js @@ -1,6 +1,8 @@ import assert from 'assert'; import path from 'path'; import {bundle, run} from '@parcel/test-utils'; +import fs from 'fs'; +import os from 'os'; describe('resolver', function() { it('should support resolving tilde in monorepo packages', async function() { @@ -258,6 +260,19 @@ describe('resolver', function() { }); it('should support symlinked node_modules structure', async function() { + const symlinks = [ + [ + '/node_modules/.origin/library@1.0.0/node_modules/library-dep', + '../../library-dep@1.0.0/node_modules/library-dep', + ], + ['/node_modules/library', '.origin/library@1.0.0/node_modules/library'], + ]; + + createSymlinks( + '/integration/resolve-symlinked-node_modules-structure', + symlinks, + ); + let b = await bundle( path.join( __dirname, @@ -265,11 +280,30 @@ describe('resolver', function() { ), ); + removeSymlinks( + '/integration/resolve-symlinked-node_modules-structure', + symlinks, + ); + let output = await run(b); assert.strictEqual(output.default, 42); }); it('should support symlinked monorepos structure', async function() { + const symlinks = [ + ['/packages/app/node_modules/library', '../../library'], + [ + '/packages/app/node_modules/pkg', + '../../../node_modules/.origin/pkg@1.0.0/node_modules/pkg', + ], + [ + '/packages/library/node_modules/pkg', + '../../../node_modules/.origin/pkg@1.0.0/node_modules/pkg', + ], + ]; + + createSymlinks('/integration/resolve-symlinked-monorepos', symlinks); + let b = await bundle( path.join( __dirname, @@ -277,7 +311,25 @@ describe('resolver', function() { ), ); + removeSymlinks('/integration/resolve-symlinked-monorepos', symlinks); + let output = await run(b); assert.strictEqual(output.default, 2); }); }); + +function createSymlinks(dir, symlinks) { + const symlinkType = os.platform() === 'win32' ? 'junction' : 'file'; + + symlinks.forEach(([linkFile, linkTarget]) => { + const file = path.join(__dirname, dir, linkFile); + fs.symlinkSync(linkTarget, file, symlinkType); + }); +} + +function removeSymlinks(dir, symlinks) { + symlinks.forEach(([linkFile]) => { + const file = path.join(__dirname, dir, linkFile); + fs.unlinkSync(file); + }); +} From 1429c5da13ba1912f4020e82a263de6ddae51957 Mon Sep 17 00:00:00 2001 From: Jasper De Moor Date: Mon, 31 Aug 2020 17:18:49 +0200 Subject: [PATCH 05/17] Update packages/utils/node-resolver-core/src/NodeResolver.js Co-authored-by: Amin Yahyaabadi --- packages/utils/node-resolver-core/src/NodeResolver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/node-resolver-core/src/NodeResolver.js b/packages/utils/node-resolver-core/src/NodeResolver.js index 52639dbc6ef..9b821661835 100644 --- a/packages/utils/node-resolver-core/src/NodeResolver.js +++ b/packages/utils/node-resolver-core/src/NodeResolver.js @@ -538,7 +538,7 @@ export default class NodeResolver { let moduleDir = path.join(dir, 'node_modules', moduleName); let stats = await this.fs.stat(moduleDir); if (stats.isDirectory()) { - const realModuleDir = this.options.inputFS.realpathSync(moduleDir); + const realModuleDir = this.options?.inputFS.realpathSync(moduleDir); return { moduleName: moduleName, subPath: subPath, From 3af4f55d7220f4046985678ecb1d718a86c33176 Mon Sep 17 00:00:00 2001 From: Jasper De Moor Date: Mon, 31 Aug 2020 17:37:47 +0200 Subject: [PATCH 06/17] Update NodeResolver.js --- packages/utils/node-resolver-core/src/NodeResolver.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/utils/node-resolver-core/src/NodeResolver.js b/packages/utils/node-resolver-core/src/NodeResolver.js index 9b821661835..e6c816a2dd9 100644 --- a/packages/utils/node-resolver-core/src/NodeResolver.js +++ b/packages/utils/node-resolver-core/src/NodeResolver.js @@ -538,7 +538,8 @@ export default class NodeResolver { let moduleDir = path.join(dir, 'node_modules', moduleName); let stats = await this.fs.stat(moduleDir); if (stats.isDirectory()) { - const realModuleDir = this.options?.inputFS.realpathSync(moduleDir); + const realModuleDir = this.options?.inputFS.realpathSync(moduleDir); + return { moduleName: moduleName, subPath: subPath, From 9af66a4347217e40727f274cdb36e335fcf7b21b Mon Sep 17 00:00:00 2001 From: Jasper De Moor Date: Mon, 31 Aug 2020 17:37:53 +0200 Subject: [PATCH 07/17] Update packages/utils/node-resolver-core/src/NodeResolver.js Co-authored-by: Amin Yahyaabadi --- packages/utils/node-resolver-core/src/NodeResolver.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/utils/node-resolver-core/src/NodeResolver.js b/packages/utils/node-resolver-core/src/NodeResolver.js index e6c816a2dd9..d8c787fb065 100644 --- a/packages/utils/node-resolver-core/src/NodeResolver.js +++ b/packages/utils/node-resolver-core/src/NodeResolver.js @@ -543,8 +543,8 @@ export default class NodeResolver { return { moduleName: moduleName, subPath: subPath, - moduleDir: realModuleDir, - filePath: path.join(realModuleDir, subPath || ''), + moduleDir: realModuleDir || moduleDir, + filePath: realModuleDir ? path.join(realModuleDir, subPath || '') : path.join(dir, 'node_modules', filename), }; } } catch (err) { From ef77778227efaa639f4ec1afec6001ecd80e005a Mon Sep 17 00:00:00 2001 From: Jasper De Moor Date: Mon, 31 Aug 2020 18:39:10 +0200 Subject: [PATCH 08/17] Update packages/utils/node-resolver-core/src/NodeResolver.js Co-authored-by: Amin Yahyaabadi --- packages/utils/node-resolver-core/src/NodeResolver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/node-resolver-core/src/NodeResolver.js b/packages/utils/node-resolver-core/src/NodeResolver.js index d8c787fb065..b53e88c8e9f 100644 --- a/packages/utils/node-resolver-core/src/NodeResolver.js +++ b/packages/utils/node-resolver-core/src/NodeResolver.js @@ -538,7 +538,7 @@ export default class NodeResolver { let moduleDir = path.join(dir, 'node_modules', moduleName); let stats = await this.fs.stat(moduleDir); if (stats.isDirectory()) { - const realModuleDir = this.options?.inputFS.realpathSync(moduleDir); + const realModuleDir = this.fs.realpathSync(moduleDir); return { moduleName: moduleName, From 0b646bd72580b95c7e5c9579e5a0d80e49a76283 Mon Sep 17 00:00:00 2001 From: dishuostec Date: Fri, 25 Sep 2020 18:00:28 +0800 Subject: [PATCH 09/17] use realpath --- .../node-resolver-core/src/NodeResolver.js | 24 +++++++++++++------ .../utils/node-resolver-core/test/resolver.js | 11 +++------ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/packages/utils/node-resolver-core/src/NodeResolver.js b/packages/utils/node-resolver-core/src/NodeResolver.js index 280f4789bc6..02beb33651b 100644 --- a/packages/utils/node-resolver-core/src/NodeResolver.js +++ b/packages/utils/node-resolver-core/src/NodeResolver.js @@ -58,6 +58,7 @@ type Module = {| subPath?: ?string, moduleDir?: FilePath, filePath?: FilePath, + isSymlink?: boolean, code?: string, |}; @@ -428,12 +429,15 @@ export default class NodeResolver { let stats = await this.fs.stat(moduleDir); if (stats.isDirectory()) { const realModuleDir = this.fs.realpathSync(moduleDir); - + return { moduleName: moduleName, subPath: subPath, moduleDir: realModuleDir || moduleDir, - filePath: realModuleDir ? path.join(realModuleDir, subPath || '') : path.join(dir, 'node_modules', filename), + filePath: realModuleDir + ? path.join(realModuleDir, subPath || '') + : path.join(dir, 'node_modules', filename), + isSymlink: realModuleDir ? realModuleDir !== moduleDir : false, }; } } catch (err) { @@ -455,7 +459,7 @@ export default class NodeResolver { // If a module was specified as a module sub-path (e.g. some-module/some/path), // it is likely a file. Try loading it as a file first. if (module.subPath && module.moduleDir) { - let pkg = await this.readPackage(module.moduleDir); + let pkg = await this.readPackage(module.moduleDir, module.isSymlink); let res = await this.loadAsFile({ file: nullthrows(module.filePath), extensions, @@ -472,6 +476,7 @@ export default class NodeResolver { dir: nullthrows(module.filePath), extensions, env, + isSymlink: module.isSymlink, }); } @@ -489,15 +494,17 @@ export default class NodeResolver { extensions, env, pkg, + isSymlink, }: {| dir: string, extensions: Array, env: Env, pkg?: InternalPackageJSON | null, + isSymlink?: boolean, |}): Promise { let failedEntry; try { - pkg = await this.readPackage(dir); + pkg = await this.readPackage(dir, isSymlink); if (pkg) { // Get a list of possible package entry points. @@ -517,6 +524,7 @@ export default class NodeResolver { extensions, env, pkg, + isSymlink, })); if (res) { @@ -581,7 +589,10 @@ export default class NodeResolver { }); } - async readPackage(dir: string): Promise { + async readPackage( + dir: string, + isSymlink: boolean = false, + ): Promise { let file = path.join(dir, 'package.json'); let cached = this.packageCache.get(file); @@ -598,8 +609,7 @@ export default class NodeResolver { // If the package has a `source` field, check if it is behind a symlink. // If so, we treat the module as source code rather than a pre-compiled module. if (pkg.source) { - let realpath = await this.fs.realpath(file); - if (realpath === file) { + if (!isSymlink) { delete pkg.source; } } diff --git a/packages/utils/node-resolver-core/test/resolver.js b/packages/utils/node-resolver-core/test/resolver.js index 419122227a7..d4a713ec351 100644 --- a/packages/utils/node-resolver-core/test/resolver.js +++ b/packages/utils/node-resolver-core/test/resolver.js @@ -693,7 +693,7 @@ describe('resolver', function() { parent: path.join(rootDir, 'foo.js'), }); assert.deepEqual(resolved, { - filePath: path.join(rootDir, 'node_modules', 'source', 'source.js'), + filePath: path.join(rootDir, 'packages', 'source', 'source.js'), sideEffects: undefined, }); }); @@ -724,12 +724,7 @@ describe('resolver', function() { parent: path.join(rootDir, 'foo.js'), }); assert.deepEqual(resolved, { - filePath: path.join( - rootDir, - 'node_modules', - 'source-alias', - 'source.js', - ), + filePath: path.join(rootDir, 'packages', 'source-alias', 'source.js'), sideEffects: undefined, }); }); @@ -744,7 +739,7 @@ describe('resolver', function() { assert.deepEqual(resolved, { filePath: path.join( rootDir, - 'node_modules', + 'packages', 'source-alias-glob', 'src', 'test.js', From 36f481b44cec1b17922208f4217d4c41f5df5970 Mon Sep 17 00:00:00 2001 From: dishuostec Date: Sat, 26 Sep 2020 10:56:08 +0800 Subject: [PATCH 10/17] Tests use overlayFS --- .../core/integration-tests/test/resolver.js | 103 +++++++++--------- 1 file changed, 53 insertions(+), 50 deletions(-) diff --git a/packages/core/integration-tests/test/resolver.js b/packages/core/integration-tests/test/resolver.js index d27f8f455f5..5a876f29e15 100644 --- a/packages/core/integration-tests/test/resolver.js +++ b/packages/core/integration-tests/test/resolver.js @@ -1,8 +1,6 @@ import assert from 'assert'; import path from 'path'; -import {bundle, run} from '@parcel/test-utils'; -import fs from 'fs'; -import os from 'os'; +import {bundle, run, ncp, overlayFS, outputFS} from '@parcel/test-utils'; describe('resolver', function() { it('should support resolving tilde in monorepo packages', async function() { @@ -260,17 +258,30 @@ describe('resolver', function() { }); it('should support symlinked node_modules structure', async function() { - const symlinks = [ - [ - '/node_modules/.origin/library@1.0.0/node_modules/library-dep', - '../../library-dep@1.0.0/node_modules/library-dep', - ], - ['/node_modules/library', '.origin/library@1.0.0/node_modules/library'], - ]; - - createSymlinks( - '/integration/resolve-symlinked-node_modules-structure', - symlinks, + 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/library@1.0.0/node_modules/library', + ), + path.join(rootDir, 'node_modules/library'), + ); + await outputFS.symlink( + path.join( + rootDir, + 'node_modules/.origin/library-dep@1.0.0/node_modules/library-dep', + ), + path.join( + rootDir, + 'node_modules/.origin/library@1.0.0/node_modules/library-dep', + ), ); let b = await bundle( @@ -278,11 +289,10 @@ describe('resolver', function() { __dirname, '/integration/resolve-symlinked-node_modules-structure/index.js', ), - ); - - removeSymlinks( - '/integration/resolve-symlinked-node_modules-structure', - symlinks, + { + inputFS: overlayFS, + outputFS, + }, ); let output = await run(b); @@ -290,46 +300,39 @@ describe('resolver', function() { }); it('should support symlinked monorepos structure', async function() { - const symlinks = [ - ['/packages/app/node_modules/library', '../../library'], - [ - '/packages/app/node_modules/pkg', - '../../../node_modules/.origin/pkg@1.0.0/node_modules/pkg', - ], - [ - '/packages/library/node_modules/pkg', - '../../../node_modules/.origin/pkg@1.0.0/node_modules/pkg', - ], - ]; - - createSymlinks('/integration/resolve-symlinked-monorepos', symlinks); + 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/pkg@1.0.0/node_modules/pkg'), + path.join(rootDir, 'packages/app/node_modules/pkg'), + ); + await outputFS.symlink( + path.join(rootDir, 'node_modules/.origin/pkg@1.0.0/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, + }, ); - removeSymlinks('/integration/resolve-symlinked-monorepos', symlinks); - let output = await run(b); assert.strictEqual(output.default, 2); }); }); - -function createSymlinks(dir, symlinks) { - const symlinkType = os.platform() === 'win32' ? 'junction' : 'file'; - - symlinks.forEach(([linkFile, linkTarget]) => { - const file = path.join(__dirname, dir, linkFile); - fs.symlinkSync(linkTarget, file, symlinkType); - }); -} - -function removeSymlinks(dir, symlinks) { - symlinks.forEach(([linkFile]) => { - const file = path.join(__dirname, dir, linkFile); - fs.unlinkSync(file); - }); -} From f8f5378168c8a0df7b5018b39f88f38eea99830a Mon Sep 17 00:00:00 2001 From: dishuostec <384801+dishuostec@users.noreply.github.com> Date: Wed, 21 Oct 2020 08:31:02 +0800 Subject: [PATCH 11/17] Update packages/utils/node-resolver-core/src/NodeResolver.js Co-authored-by: Amin Yahyaabadi --- packages/utils/node-resolver-core/src/NodeResolver.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/node-resolver-core/src/NodeResolver.js b/packages/utils/node-resolver-core/src/NodeResolver.js index 4ee4497cac9..fa9eeefdf26 100644 --- a/packages/utils/node-resolver-core/src/NodeResolver.js +++ b/packages/utils/node-resolver-core/src/NodeResolver.js @@ -430,7 +430,7 @@ export default class NodeResolver { let moduleDir = path.join(dir, 'node_modules', moduleName); let stats = await this.fs.stat(moduleDir); if (stats.isDirectory()) { - const realModuleDir = this.fs.realpathSync(moduleDir); + const realModuleDir = await this.fs.realpath(moduleDir); return { moduleName: moduleName, From 77bfe860700df311381d1d1a6963149704ccd82f Mon Sep 17 00:00:00 2001 From: Devon Govett Date: Sun, 20 Dec 2020 14:37:16 -0500 Subject: [PATCH 12/17] Realpath at the end of resolution --- packages/utils/node-resolver-core/src/NodeResolver.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/utils/node-resolver-core/src/NodeResolver.js b/packages/utils/node-resolver-core/src/NodeResolver.js index eb8ad08f8a1..ca2c97ff3f1 100644 --- a/packages/utils/node-resolver-core/src/NodeResolver.js +++ b/packages/utils/node-resolver-core/src/NodeResolver.js @@ -136,7 +136,7 @@ export default class NodeResolver { } else if (module.filePath) { if (module.code != null) { return { - filePath: module.filePath, + filePath: await this.fs.realpath(module.filePath), code: module.code, }; } @@ -151,7 +151,7 @@ export default class NodeResolver { if (resolved) { return { - filePath: resolved.path, + filePath: await this.fs.realpath(resolved.path), sideEffects: resolved.pkg && !this.hasSideEffects(resolved.path, resolved.pkg) ? false From 2e3b9379b44fa3eba87eadaa7efe73a21e9591f8 Mon Sep 17 00:00:00 2001 From: Devon Govett Date: Sun, 20 Dec 2020 14:37:31 -0500 Subject: [PATCH 13/17] Remove realpaths that are now unnecessary --- packages/core/core/src/requests/AssetRequest.js | 5 ++--- packages/core/core/src/summarizeRequest.js | 13 ++++--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/core/core/src/requests/AssetRequest.js b/packages/core/core/src/requests/AssetRequest.js index 4515d909d5a..03d9fe4511a 100644 --- a/packages/core/core/src/requests/AssetRequest.js +++ b/packages/core/core/src/requests/AssetRequest.js @@ -56,8 +56,7 @@ function getId(input: AssetRequestInput) { } async function run({input, api, options, farm}: RunInput) { - let realpath = await options.inputFS.realpath(input.filePath); - api.invalidateOnFileUpdate(realpath); + api.invalidateOnFileUpdate(input.filePath); let start = Date.now(); let {optionsRef, ...request} = input; let {cachePath} = nullthrows( @@ -68,7 +67,7 @@ async function run({input, api, options, farm}: RunInput) { // These are used to compute the cache key for assets during transformation. request.invalidations = api.getInvalidations().filter(invalidation => { // Filter out invalidation node for the input file itself. - return invalidation.type !== 'file' || invalidation.filePath !== realpath; + return invalidation.type !== 'file' || invalidation.filePath !== input.filePath; }); let {assets, configRequests, invalidations} = (await farm.createHandle( diff --git a/packages/core/core/src/summarizeRequest.js b/packages/core/core/src/summarizeRequest.js index dff7a2fb6c7..a1cfa122780 100644 --- a/packages/core/core/src/summarizeRequest.js +++ b/packages/core/core/src/summarizeRequest.js @@ -13,18 +13,13 @@ export default async function summarizeRequest( fs: FileSystem, req: {|filePath: FilePath, code?: string|}, ): Promise<{|content: Blob, hash: string, size: number, isSource: boolean|}> { - let [{content, hash, size}, isSource] = await Promise.all([ - summarizeDiskRequest(fs, req), - isFilePathSource(fs, req.filePath), - ]); + let {content, hash, size} = await summarizeDiskRequest(fs, req); + let isSource = isFilePathSource(fs, req.filePath); return {content, hash, size, isSource}; } -async function isFilePathSource(fs: FileSystem, filePath: FilePath) { - return ( - !filePath.includes(NODE_MODULES) || - (await fs.realpath(filePath)) !== filePath - ); +function isFilePathSource(fs: FileSystem, filePath: FilePath) { + return !filePath.includes(NODE_MODULES); } async function summarizeDiskRequest( From 55e9c3faa40c070849183c9d49859dd6eb4d9bc4 Mon Sep 17 00:00:00 2001 From: Devon Govett Date: Sun, 20 Dec 2020 14:51:18 -0500 Subject: [PATCH 14/17] Fix sourcemaps tests --- packages/core/integration-tests/test/sourcemaps.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/integration-tests/test/sourcemaps.js b/packages/core/integration-tests/test/sourcemaps.js index 383ad95b1b3..49650f2b906 100644 --- a/packages/core/integration-tests/test/sourcemaps.js +++ b/packages/core/integration-tests/test/sourcemaps.js @@ -462,7 +462,7 @@ describe('sourcemaps', function() { assert.equal(mapData.sources.length, 2); assert.deepEqual(mapData.sources, [ './index.ts', - '../../../../../../node_modules/@parcel/transformer-js/src/esmodule-helpers.js', + '../../../../../transformers/js/src/esmodule-helpers.js', ]); let input = await inputFS.readFile( @@ -505,7 +505,7 @@ describe('sourcemaps', function() { assert.deepEqual(mapData.sources, [ './index.ts', './local.ts', - '../../../../../../node_modules/@parcel/transformer-js/src/esmodule-helpers.js', + '../../../../../transformers/js/src/esmodule-helpers.js', ]); let input = await inputFS.readFile( @@ -959,7 +959,7 @@ describe('sourcemaps', function() { assert.equal(map.file, 'index.js.map'); assert.deepEqual(map.sources, [ './index.js', - '../../../../../../node_modules/@parcel/transformer-js/src/esmodule-helpers.js', + '../../../../../transformers/js/src/esmodule-helpers.js', ]); assert.equal(map.sourcesContent[0], sourceContent); }); @@ -993,7 +993,7 @@ describe('sourcemaps', function() { assert.equal(map.file, 'index.js.map'); assert.deepEqual(map.sources, [ './index.js', - '../../../../../../node_modules/@parcel/transformer-js/src/esmodule-helpers.js', + '../../../../../transformers/js/src/esmodule-helpers.js', ]); }); From 56d98f4e03eb8cf7dc3b0010d179ed06094c406d Mon Sep 17 00:00:00 2001 From: Devon Govett Date: Sun, 20 Dec 2020 14:52:20 -0500 Subject: [PATCH 15/17] Add tests for symlink resolution --- .../utils/node-resolver-core/test/resolver.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/packages/utils/node-resolver-core/test/resolver.js b/packages/utils/node-resolver-core/test/resolver.js index 000882753db..18a53da969b 100644 --- a/packages/utils/node-resolver-core/test/resolver.js +++ b/packages/utils/node-resolver-core/test/resolver.js @@ -52,6 +52,14 @@ describe('resolver', function() { path.join(rootDir, 'packages/source-alias-glob'), path.join(rootDir, 'node_modules/source-alias-glob'), ); + await outputFS.symlink( + path.join(rootDir, 'bar.js'), + path.join(rootDir, 'baz.js') + ); + await outputFS.symlink( + path.join(rootDir, 'nested'), + path.join(rootDir, 'symlinked-nested') + ); resolver = new NodeResolver({ fs: overlayFS, @@ -749,6 +757,28 @@ describe('resolver', function() { }); }); + describe('symlinks', function () { + it('should resolve symlinked files to their realpath', async function () { + let resolved = await resolver.resolve({ + env: BROWSER_ENV, + filename: './baz.js', + isURL: false, + parent: path.join(rootDir, 'foo.js'), + }); + assert.equal(nullthrows(resolved).filePath, path.join(rootDir, 'bar.js')); + }); + + it('should resolve symlinked directories to their realpath', async function () { + let resolved = await resolver.resolve({ + env: BROWSER_ENV, + filename: './symlinked-nested', + isURL: false, + parent: path.join(rootDir, 'foo.js'), + }); + assert.equal(nullthrows(resolved).filePath, path.join(rootDir, 'nested', 'index.js')); + }); + }); + describe('error handling', function() { it('should return diagnostics when package.module does not exist', async function() { let result = await resolver.resolve({ From 286d3e25b28131706a055e372fc7473f3871d5d7 Mon Sep 17 00:00:00 2001 From: Devon Govett Date: Sun, 20 Dec 2020 14:53:27 -0500 Subject: [PATCH 16/17] Remove realpath comment --- packages/core/utils/src/config.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/core/utils/src/config.js b/packages/core/utils/src/config.js index 090e5889429..37a5c145875 100644 --- a/packages/core/utils/src/config.js +++ b/packages/core/utils/src/config.js @@ -21,7 +21,6 @@ export function resolveConfig( filepath: FilePath, filenames: Array, ): Promise { - // TODO: realpath return Promise.resolve( fs.findAncestorFile(filenames, path.dirname(filepath)), ); @@ -32,7 +31,6 @@ export function resolveConfigSync( filepath: FilePath, filenames: Array, ): ?FilePath { - // TODO: realpath return fs.findAncestorFile(filenames, path.dirname(filepath)); } From 4f3fe28191f871c1e086ab99f361c5b6a03f7c81 Mon Sep 17 00:00:00 2001 From: Devon Govett Date: Sun, 20 Dec 2020 16:13:52 -0500 Subject: [PATCH 17/17] prettier --- packages/core/core/src/requests/AssetRequest.js | 4 +++- .../utils/node-resolver-core/test/resolver.js | 15 +++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/core/core/src/requests/AssetRequest.js b/packages/core/core/src/requests/AssetRequest.js index 03d9fe4511a..5f69cda78fd 100644 --- a/packages/core/core/src/requests/AssetRequest.js +++ b/packages/core/core/src/requests/AssetRequest.js @@ -67,7 +67,9 @@ async function run({input, api, options, farm}: RunInput) { // These are used to compute the cache key for assets during transformation. request.invalidations = api.getInvalidations().filter(invalidation => { // Filter out invalidation node for the input file itself. - return invalidation.type !== 'file' || invalidation.filePath !== input.filePath; + return ( + invalidation.type !== 'file' || invalidation.filePath !== input.filePath + ); }); let {assets, configRequests, invalidations} = (await farm.createHandle( diff --git a/packages/utils/node-resolver-core/test/resolver.js b/packages/utils/node-resolver-core/test/resolver.js index 18a53da969b..867bad1bc81 100644 --- a/packages/utils/node-resolver-core/test/resolver.js +++ b/packages/utils/node-resolver-core/test/resolver.js @@ -54,11 +54,11 @@ describe('resolver', function() { ); await outputFS.symlink( path.join(rootDir, 'bar.js'), - path.join(rootDir, 'baz.js') + path.join(rootDir, 'baz.js'), ); await outputFS.symlink( path.join(rootDir, 'nested'), - path.join(rootDir, 'symlinked-nested') + path.join(rootDir, 'symlinked-nested'), ); resolver = new NodeResolver({ @@ -757,8 +757,8 @@ describe('resolver', function() { }); }); - describe('symlinks', function () { - it('should resolve symlinked files to their realpath', async function () { + describe('symlinks', function() { + it('should resolve symlinked files to their realpath', async function() { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: './baz.js', @@ -768,14 +768,17 @@ describe('resolver', function() { assert.equal(nullthrows(resolved).filePath, path.join(rootDir, 'bar.js')); }); - it('should resolve symlinked directories to their realpath', async function () { + it('should resolve symlinked directories to their realpath', async function() { let resolved = await resolver.resolve({ env: BROWSER_ENV, filename: './symlinked-nested', isURL: false, parent: path.join(rootDir, 'foo.js'), }); - assert.equal(nullthrows(resolved).filePath, path.join(rootDir, 'nested', 'index.js')); + assert.equal( + nullthrows(resolved).filePath, + path.join(rootDir, 'nested', 'index.js'), + ); }); });