Skip to content

Commit

Permalink
add require() shim for requires not transformed by esbuild
Browse files Browse the repository at this point in the history
esbuild doesn't seem to transform require()s of Node builtins into
imports, so define a global.require for them.
  • Loading branch information
Conduitry committed Jun 7, 2021
1 parent 6670841 commit 015375d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/adapter-node/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './require_shim';
import { createServer } from './server';
// TODO hardcoding the relative location makes this brittle
import { render } from '../output/server/app.js'; // eslint-disable-line import/no-unresolved
Expand Down
2 changes: 2 additions & 0 deletions packages/adapter-node/src/require_shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { createRequire } from 'module';
global.require = createRequire(import.meta.url);

0 comments on commit 015375d

Please sign in to comment.