RequireJS shim config in webpack

579 views Asked by At

I want to port my requirejs web application to webpack module bundler. The app use several non AMD libraries (such jquery and bootstrap). RequireJS maintains such libraries via shim configuration. How I can declare dependincies for non AMD libraries in webpack?

1

There are 1 answers

0
kyranjamie On

I'm in the process of doing the same. It's practically as you would any AMD module. To use stringified templates put into AngularJS' $templateCache as an example:

Templates are generated in non-AMD format wrapped in an IIFE, pushed into a .tmp dir, then requested as per any module:

define([
  './module',
  'templates/ubCampaignEditor'
]

As to keep definitions clean, I've created a resolve.alias named templates, in the Webpack config:

resolve: {
  alias: {
    templates: path.join(__dirname, '.tmp/templates')
  }
}