esbuild-plugin-global-externals
esbuild-plugins
esbuild-plugin-global-externals | esbuild-plugins | |
---|---|---|
1 | 2 | |
38 | 274 | |
- | - | |
3.6 | 3.5 | |
almost 3 years ago | 9 months ago | |
TypeScript | JavaScript | |
MIT License | - |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
esbuild-plugin-global-externals
-
Software devs, how have you sped up your workflow?
The only thing that tripped me up was the difference between esbuild's `externals` and webpack's `externals`. In webpack you can use the externals config to skip bundling a module and instead get it from another source such as a Node module or, in my case, from a global variable in the browser. In esbuild, an external module is only for the first situation (getting a module from Node instead of bundling it), so I was confused about how I can transfer the desired behavior over to esbuild. Luckily I found a plugin that does exactly what I want: [0].
Other than that, I'm pretty darn satisfied with what esbuild can do out of the box. I don't use any other plugins except global externals, and I don't find myself missing anything from webpack. So far it's just better in every way (for myself at least).
[0]: https://github.com/fal-works/esbuild-plugin-global-externals
esbuild-plugins
-
How to use Winston in Vite
// yarn add --dev @esbuild-plugins/node-globals-polyfill import { NodeGlobalsPolyfillPlugin } from "@esbuild-plugins/node-globals-polyfill"; // yarn add --dev @esbuild-plugins/node-modules-polyfill import { NodeModulesPolyfillPlugin } from "@esbuild-plugins/node-modules-polyfill"; // You don't need to add this to deps, it's included by @esbuild-plugins/node-modules-polyfill import rollupNodePolyFill from "rollup-plugin-node-polyfills"; import react from "@vitejs/plugin-react"; import tsconfigPaths from "vite-tsconfig-paths"; export default { plugins: [ react(), tsconfigPaths(), { name: "fix-node-globals-polyfill", setup(build) { build.onResolve({ filter: /util\.js/ }, ({ path }) => ({ path })); }, }, ], resolve: { alias: { // This Rollup aliases are extracted from @esbuild-plugins/node-modules-polyfill, // see https://github.com/remorses/esbuild-plugins/blob/master/node-modules-polyfill/src/polyfills.ts // process and buffer are excluded because already managed // by node-globals-polyfill util: "util", sys: "util", events: "rollup-plugin-node-polyfills/polyfills/events", stream: "rollup-plugin-node-polyfills/polyfills/stream", path: "rollup-plugin-node-polyfills/polyfills/path", querystring: "rollup-plugin-node-polyfills/polyfills/qs", punycode: "rollup-plugin-node-polyfills/polyfills/punycode", url: "rollup-plugin-node-polyfills/polyfills/url", /******** Remove the string decoder below *********/ // string_decoder: "rollup-plugin-node-polyfills/polyfills/string-decoder", http: "rollup-plugin-node-polyfills/polyfills/http", https: "rollup-plugin-node-polyfills/polyfills/http", os: "rollup-plugin-node-polyfills/polyfills/os", assert: "rollup-plugin-node-polyfills/polyfills/assert", constants: "rollup-plugin-node-polyfills/polyfills/constants", _stream_duplex: "rollup-plugin-node-polyfills/polyfills/readable-stream/duplex", _stream_passthrough: "rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough", _stream_readable: "rollup-plugin-node-polyfills/polyfills/readable-stream/readable", _stream_writable: "rollup-plugin-node-polyfills/polyfills/readable-stream/writable", _stream_transform: "rollup-plugin-node-polyfills/polyfills/readable-stream/transform", timers: "rollup-plugin-node-polyfills/polyfills/timers", console: "rollup-plugin-node-polyfills/polyfills/console", vm: "rollup-plugin-node-polyfills/polyfills/vm", zlib: "rollup-plugin-node-polyfills/polyfills/zlib", tty: "rollup-plugin-node-polyfills/polyfills/tty", domain: "rollup-plugin-node-polyfills/polyfills/domain", }, }, optimizeDeps: { esbuildOptions: { /********* New line inserted ***********/ inject: ['./vite-polyfills/setImmediate.js'], // Node.js global to browser globalThis define: { global: "globalThis", }, // Enable esbuild polyfill plugins plugins: [ NodeGlobalsPolyfillPlugin({ process: true, buffer: true, }), NodeModulesPolyfillPlugin(), ], }, }, build: { rollupOptions: { plugins: [ // Enable rollup polyfills plugin // used during production bundling rollupNodePolyFill(), ], }, }, };
-
React Components to PDF API with CloudRun and Terraform
import react from "@vitejs/plugin-react"; import { defineConfig } from "vite"; // You don't need to add this to deps, it's included by @esbuild-plugins/node-modules-polyfill export default defineConfig({ plugins: [react()], server: { port: 3001, }, resolve: { alias: { // This Rollup aliases are extracted from @esbuild-plugins/node-modules-polyfill, // see https://github.com/remorses/esbuild-plugins/blob/master/node-modules-polyfill/src/polyfills.ts // process and buffer are excluded because already managed // by node-globals-polyfill util: "rollup-plugin-node-polyfills/polyfills/util", sys: "util", events: "rollup-plugin-node-polyfills/polyfills/events", stream: "rollup-plugin-node-polyfills/polyfills/stream", path: "rollup-plugin-node-polyfills/polyfills/path", querystring: "rollup-plugin-node-polyfills/polyfills/qs", punycode: "rollup-plugin-node-polyfills/polyfills/punycode", url: "rollup-plugin-node-polyfills/polyfills/url", string_decoder: "rollup-plugin-node-polyfills/polyfills/string-decoder", buffer: "rollup-plugin-node-polyfills/polyfills/buffer-es6", process: "rollup-plugin-node-polyfills/polyfills/process-es6", http: "rollup-plugin-node-polyfills/polyfills/http", https: "rollup-plugin-node-polyfills/polyfills/http", os: "rollup-plugin-node-polyfills/polyfills/os", assert: "rollup-plugin-node-polyfills/polyfills/assert", constants: "rollup-plugin-node-polyfills/polyfills/constants", _stream_duplex: "rollup-plugin-node-polyfills/polyfills/readable-stream/duplex", _stream_passthrough: "rollup-plugin-node-polyfills/polyfills/readable-stream/passthrough", _stream_readable: "rollup-plugin-node-polyfills/polyfills/readable-stream/readable", _stream_writable: "rollup-plugin-node-polyfills/polyfills/readable-stream/writable", _stream_transform: "rollup-plugin-node-polyfills/polyfills/readable-stream/transform", timers: "rollup-plugin-node-polyfills/polyfills/timers", console: "rollup-plugin-node-polyfills/polyfills/console", vm: "rollup-plugin-node-polyfills/polyfills/vm", zlib: "rollup-plugin-node-polyfills/polyfills/zlib", tty: "rollup-plugin-node-polyfills/polyfills/tty", domain: "rollup-plugin-node-polyfills/polyfills/domain", }, }, });
What are some alternatives?
esbuild-loader - Webpack loader for esbuild: Speed up your build ⚡️
winston - A logger for just about everything.
esbuild-plugins - ESBuild plugins by @LinbuduLab
vite-plugin-cloudflare - 🔥 Easier and better experience writing Cloudflare workers in Vite
dotfiles - @holman does dotfiles
Newman - Newman is a command-line collection runner for Postman
esbuild-plugin-prismjs - A PrismJS plugin for esbuild. Bundle the language and plugins set in the configuration at build time. The same options as babel-plugin-prismjs are available.
Codetree - ⚡️ Lightning fast off-on/line code playground, built with ♥️ on top of webAssembly.