Venryx/webpack-runtime-require

error with latest webpack

Closed this issue · 3 comments

hello sir.
I have a problem with latest webpack. I am currently using webpack 4.6.0 and I have created a sample project for repro here : https://github.com/rostacik/webpack-runtime-require-sample

I tried steps from your description, but all I get is : "[failed to retrieve module exports]"

Require doesn't work for my lib nor for jQuery I used as sample 3rd party lib.

thx in advance

Have you tried running Require() in the console, and then typing Require. and seeing what the autocomplete shows? It's possible you're trying to reference the modules by a name different than its storing them as.

Anyway, I'm cloning the repo and looking into it now.

Okay, I found the issue and solved it. The problem was that the library was not handling the situation where the webpack modules were wrapped in eval calls, since the regex was looking for require("...") instead of require(\"...\").

I've confirmed that it now works for your demo (the wpRuntimeRequireNoBundles version at least), and published a new version with the fix. (0.3.0)

To confirm it works in your demo, run these in the console:

Require()
Require.moduleA.moduleAFn1
Require.jquery
Require("moduleA").moduleAFn1
Require("jquery")

works on my machine, thx sir!