Apply bootloader to a specific file

I follow http://alexomara.com/blog/webpack-and-jquery-include-only-the-parts-you-need to link jQuery parts using webpack.

// webpack.config.js
module.exports = {
    entry: './entry',
    output: {
        filename: 'bundle.js'
    },
    module: {
        loaders: [
            { 
                test: /jquery\/src\/selector\.js$/, 
                loader: 'amd-define-factory-patcher-loader' 
            }
        ]
    }
};

It turns out that it node_modules/jquery/src/selector.jsneeds its own bootloader due to a problem with AMD. But the bootloader does not apply. I work under windows, and maybe you need to set up regex? I tried different expressions but no luck.

Any suggestions for debugging? New in webpack.

As I said, I added:

profile: true,
stats: {
  reasons: true,
  chunkModules: true,
  chunkOrigins: true,
  modules: true,
  cached: true,
  cachedAssets: true,
  source: true,
  errorDetails: true,
  publicPath: true,
  excludeModules: [
    /e\.js/
  ]

Launch webpack --display-modulesgives

Hash: 4a092c0d4d9e158a9bd7
Version: webpack 1.10.1
Time: 970ms
    Asset    Size  Chunks             Chunk Names
   bundle.js  876 kB       0  [emitted]  main
[0] ./entry.js 529 bytes {0} [built]
   factory:13ms building:12ms = 25ms
...
[14] ./~/jquery/src/traversing/var/rneedsContext.js 110 bytes {0} [built]
   [0] 25ms -> [11] 161ms -> [13] 473ms -> factory:196ms building:3ms dependencies:1ms = 859ms
[15] ./~/jquery/src/selector.js 33 bytes {0} [built]
   [0] 25ms -> [16] 172ms -> factory:449ms building:180ms = 826ms
[16] ./~/jquery/src/manipulation.js 15 kB {0} [built]
   [0] 25ms -> factory:16ms building:156ms dependencies:443ms = 640ms
...

No mistakes. Nothing of real value.

+4
source share
2 answers

-, Webpack , Windows.

, * nix, Windows.

{ test: /jquery[\\\/]src[\\\/]selector\.js$/, loader: 'amd-define-factory-patcher-loader' }

, . - , !

: , , .

+5

, - , :

http://alexomara.com/blog/webpack-and-jquery-include-only-the-parts-you-need/

Windows :

test: /jquery\\src\\selector\.js$/, loader: "amd-define-factory-patcher-loader"

, !

+1

Source: https://habr.com/ru/post/1598880/


All Articles