Skip to content

Commit

Permalink
feat: pnpm-style symlinking (#636) (#657)
Browse files Browse the repository at this point in the history
* chore: add repro test for pnpm-style symlinking

* chore: show that it works with esbuild-based bundlers

Co-authored-by: Netlify Team Account 1 <netlify-team-account-1@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Sep 29, 2021
1 parent 3c4f32a commit a6d6abb
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/fixtures/node-module-symlinks/function.js
@@ -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
@@ -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
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
const isEven = require(`${tmpDir}/function`)
// eslint-disable-next-line no-magic-numbers
t.is(isEven(10), '10 is even')
})

1 comment on commit a6d6abb

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

⏱ Benchmark results

largeDepsEsbuild: 12.6s

largeDepsZisi: 1m 9.6s

Please sign in to comment.