How to I use a CommonJS loader first rather than an AMD loader?

I’m trying to load exoskeleton and it has an AMD dependency on jquery but this isn’t a hard dependency which is checked using try/catch if the CommonJS init block is executed.

It seems that webpack uses an AMD loader by default (or at least first) because require.amd is a truthy value. How can I use a CommonJS loader instead of AMD?

I’ve tried the amd: false webpack config and that didn’t seem to work.

Also, I believe I would also have to use this settings as well, correct?

    plugins: [
        new webpack.IgnorePlugin(/^jquery$/)
    ],

Thank you very much.

Author: Fantashit

1 thought on “How to I use a CommonJS loader first rather than an AMD loader?

  1. If anyone else has this issue, I wanted a webpack.config.js configuration rather than one that must be used with the require statement itself. I did it using the following config

        plugins: [
            // ignjore "jquery" because exoskeleton will try to load it
            new webpack.IgnorePlugin(/^jquery$/)
        ],
    

    and

            loaders: [
                { test: /exoskeleton\.js$/,    loader: "imports?define=>false"},
                { test: /backbone\.js$/,    loader: "imports?define=>false"},
                ...
    

    And you must install https://github.com/webpack/imports-loader

Comments are closed.