Skip to content

Commit

Permalink
esbuild.config.cjs: revert 8e0a59 as it has undesired side-effects (#95)
Browse files Browse the repository at this point in the history
Signed-off-by: António Meireles <antonio.meireles@reformi.st>
  • Loading branch information
AntonioMeireles committed Feb 7, 2022
1 parent 39d39c6 commit a6b122f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion esbuild.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ const fs = require('fs')

const esbuild = require('esbuild')

// XXX taken from https://github.com/evanw/esbuild/issues/619#issuecomment-751995294
// XXX `plugins: [makeAllPackagesExternalPlugin]` were supposed to be superceeded by
// XXX `external: ['./node_modules/*']` but...
// XXX ... we're blocked by what seems to be https://github.com/evanw/esbuild/issues/1958
const makeAllPackagesExternalPlugin = {
name: 'make-all-packages-external',
setup: (build) => {
const filter = /^[^./]|^\.[^./]|^\.\.[^/]/ // Must not start with "/" or "./" or "../"
build.onResolve({ filter }, (arguments_) => ({ external: true, path: arguments_.path }))
}
}

const catcher = (error) => {
console.error(error)
// eslint-disable-next-line unicorn/no-process-exit
Expand All @@ -21,7 +33,7 @@ const builder = (entryPoints, outdir = 'dist', platform = targets.Node) =>
platform,
sourcemap: true,
...(platform === targets.Node
? { external: ['./node_modules/*'], target: 'node14' }
? { plugins: [makeAllPackagesExternalPlugin], target: 'node14' }
: {
inject: ['src/ui/react-shim.ts'],
jsxFactory: 'h',
Expand Down

0 comments on commit a6b122f

Please sign in to comment.