Skip to content
This repository has been archived by the owner on Mar 25, 2022. It is now read-only.

dynamicRequire Error when bundling with rollup #28

Open
prakattuladhar opened this issue Aug 2, 2021 · 2 comments
Open

dynamicRequire Error when bundling with rollup #28

prakattuladhar opened this issue Aug 2, 2021 · 2 comments

Comments

@prakattuladhar
Copy link

The following code in index.js causes files built using rollup to throw error during runtime.
(Error: Could not dynamically require "/build/reserved.js". ).

// index.js
var reservedMap = require(__dirname + '/reserved.js'); 

For now I've used dynamicRequireTargets with @rollup/plugin-commonjs plugin to resolve this issue.

plugins:[...,
commonjs({
      dynamicRequireTargets: ["node_modules/pg-format/lib/*.js"],
    })
],
@Rauttis
Copy link

Rauttis commented Aug 17, 2021

Same issue when bundling with esbuild. Webpack seems to handle this gracefully, but most other bundlers either break during bundling or just leave the file out and break during runtime.

@mattfysh
Copy link

mattfysh commented Oct 6, 2021

Anyone know of a workaround for esbuild?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants