Skip to content

Instantly share code, notes, and snippets.

@jbaiter
Last active September 5, 2023 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbaiter/e830fb9fd5b2de5bc9d8db341c91bf94 to your computer and use it in GitHub Desktop.
Save jbaiter/e830fb9fd5b2de5bc9d8db341c91bf94 to your computer and use it in GitHub Desktop.
Minimal sample to reproduce esbuild bug with disabled dependencies
import nodeFetch from 'node-fetch';
let fetchImpl;
if (typeof fetch !== 'undefined') {
fetchImpl = fetch;
console.log('Using browser fetch');
} else {
console.log('Using node-fetch');
fetchImpl = nodeFetch;
}
{
"name": "esbuild-disabled-dep",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"run-vite": "vite",
"build": "esbuild index.js --bundle --outfile=./out.js",
"build-rollup": "vite build"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"node-fetch": "^3.3.2"
},
"devDependencies": {
"esbuild": "^0.19.2",
"vite": "^4.4.9"
},
"browser": {
"node-fetch": false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment