hapijs / glue

Server composer for hapi.js
Other
245 stars 62 forks source link

Integration with webpack - dynamic import issue #115

Closed no-more closed 6 years ago

no-more commented 6 years ago

Context

What are you trying to achieve or the steps to reproduce ?

I would like to bundle my project with webpack including node_modules required by the application. The issue is that Glue use dynamic imports from the config json data and thus there's no direct import of the plugins in the application. This result in errors in webpack that does not support dynamic imports.

Describe your issue here, include manifests and plugin objects if needed.

What result did you get ?

In the bundle file the plugins are missing and the require statement in glue is replaced with an error from webpack: Currently the original code plugin.register = require(path); is replaced by plugin.register = !(function webpackMissingModule() { var e = new Error("Cannot find module \".\""); e.code = 'MODULE_NOT_FOUND'; throw e; }());.

What did you expect ?

I'm looking for a way to bundle the package with webpack in order to deliver a single file without node_modules folder which is not available in my case because I'm using yarn workspace feature (so the node_modules folder is outside of the project directory and not accessible to create a docker container.

csrl commented 6 years ago

In the past, it seems the response within the hapi ecosystem on these requests has been that the target is a standard node.js environment. However, if you have a patch that supports your need and doesn't complicate the node.js target, I'm open to reviewing it.

Marsup commented 6 years ago

IMHO it's the developer's task to use require.ensure or whatever satisfies webpack to do that, not glue's.

no-more commented 6 years ago

With newer version of glue it's possible to requires the plugins so it's no longer an issue.

Thanks for this great tool.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.