0
votes

Currently I'm using RequireJS for all my modules. I'm considering using Webpack for my main project but need to load modules not known during build time. Like plugins.

One approach would be to use Webpack at build time and then use RequireJS at runtime. The only problem is that files loaded from Webpack bundle won't be found in the RequireJS cache.

If I manually register them it works:

import jQuery from 'jquery';
define('jquery', [], function() { return jQuery; });

But is there some easier way? Like Webpack generating code that does this?

1

1 Answers

0
votes

I ended up writing a custom loader that added the code at the end of each file. Using window.define instead of define makes Webpack leave it intact for RequireJS.