Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

feat: pnpm-style symlinking (#636) #657

Merged
merged 4 commits into from
Sep 29, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/fixtures/node-module-symlinks/function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const isEven = require('is-even')

module.exports = (number) => (isEven(number) ? `${number} is even` : `${number} is odd`)
1 change: 1 addition & 0 deletions tests/fixtures/node-module-symlinks/node_modules/is-even

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/fixtures/node-module-symlinks/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"is-even": "^1.0.0"
}
}

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.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1976,3 +1976,14 @@ test('Creates a manifest file with the list of created functions if the `manifes
t.is(fn.path, file.path)
})
})

testBundlers('Correctly follows node_modules via symlink', [ESBUILD, ESBUILD_ZISI], async (bundler, t) => {
const { tmpDir } = await zipNode(t, 'node-module-symlinks', {
opts: { config: { '*': { nodeBundler: bundler } } },
})

// eslint-disable-next-line import/no-dynamic-require, node/global-require
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to remove these once we land #682.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#682 is only about fixtures, not about test code. We could add // eslint-disable-file import/no-dynamic-require, node/global-require to the top of this file instead of line-by-line, though!

const isEven = require(`${tmpDir}/function`)
// eslint-disable-next-line no-magic-numbers
t.is(isEven(10), '10 is even')
})