Skip to content

Koa-body 6.0.1 bundling Issue - Cannot find module octetstream.js #1706

Answered by keymandll
keymandll asked this question in Q&A
Discussion options

You must be logged in to vote

I think i figured it out. Koa-body (at the moment) uses formidable 2.x, which dynamically imports the plugins based on the plugin names specified via the enabledPlugins option. The relevant snippet from the bundled code:

        this.options.enabledPlugins.forEach((pluginName) => {
          const plgName = pluginName.toLowerCase();
          this.use(require(path.join(__dirname, "plugins", `${plgName}.js`)));
        });

This is unfortunate, because from esbuild's perspective the plugins are non-analyzable imports, quoting:

Bundling with esbuild only works with statically-defined imports (i.e. when the import path is a string literal). Imports that are defined at run-time (i.e. imports…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@nickchampion
Comment options

@ad-zsolt-imre
Comment options

Answer selected by keymandll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants