This repository has been archived by the owner on May 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
fix: detect native bindings and change extension priority #353
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bdcf286
fix: remove externalModules optimisation
eduardoboucas 174a38c
fix: add esbuild plugin for node-fetch
eduardoboucas 508ea00
chore: skip esbuild plugins in Node 8
eduardoboucas cd81510
feat: add plugin for native bindings
eduardoboucas 24d0303
chore: fix ESLint warning
eduardoboucas 7b8343a
chore: pass populated context to plugins
eduardoboucas 2e32740
chore: fix tests
eduardoboucas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,22 @@ | ||
const { relative, resolve } = require('path') | ||
|
||
const getNodeBindingHandlerPlugin = ({ basePath, context }) => ({ | ||
name: 'node-binding-handler', | ||
setup(build) { | ||
build.onResolve({ filter: /\.node$/ }, (args) => { | ||
const fullPath = resolve(args.resolveDir, args.path) | ||
const resolvedPath = relative(basePath, fullPath) | ||
|
||
context.nodeBindings.add(fullPath) | ||
|
||
return { | ||
external: true, | ||
path: resolvedPath, | ||
} | ||
}) | ||
}, | ||
}) | ||
|
||
const getPlugins = ({ basePath, context }) => [getNodeBindingHandlerPlugin({ basePath, context })] | ||
|
||
module.exports = { getPlugins } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const fetch = require('node-fetch') | ||
|
||
module.exports = fetch |
4 changes: 4 additions & 0 deletions
4
tests/fixtures/node-fetch/node_modules/node-fetch/lib/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
tests/fixtures/node-fetch/node_modules/node-fetch/lib/index.mjs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
tests/fixtures/node-fetch/node_modules/node-fetch/package.json
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,7 @@ | ||
{ | ||
"name": "function-requiring-node-fetch", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"node-fetch": "^2.6.1" | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
.es6
be added? This is an old extension that was used in the past when ES6 became a thing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I'll make a note to do some testing and add that in a subsequent PR.