Description: [PATCH 1/2] upgrade webpack
Author: Jishnu Mohan <jishnu7@gmail.com>
Forwarded: not-needed
Reviewed-By: Xavier Guimard <yadd@debian.org>
Last-Update: 2020-02-03

--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,4 +1,6 @@
 /* eslint-disable no-process-env */
+const path = require('path');
+
 module.exports = function(grunt) {
   grunt.initConfig({
     pkg: grunt.file.readJSON('package.json'),
@@ -16,18 +18,14 @@
           processContent: function(content) {
             return (
               grunt.template.process(
-                '/**!\n\n @license\n <%= pkg.name %> v<%= pkg.version %>\n\n<%= grunt.file.read("LICENSE") %>\n*/\n'
-              ) + content
+                '/**!\n\n @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat\n <%= pkg.name %> v<%= pkg.version %>\n\n<%= grunt.file.read("LICENSE") %>\n*/\n')
+                + content
+                + '\n// @license-end\n'
             );
           }
         },
         files: [{ expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/' }]
       },
-      cdnjs: {
-        files: [
-          { expand: true, cwd: 'dist/', src: ['*.js'], dest: 'dist/cdnjs' }
-        ]
-      },
       components: {
         files: [
           {
@@ -44,27 +42,15 @@
     babel: {
       options: {
         sourceMaps: 'inline',
-        loose: ['es6.modules'],
+        presets: [
+          ['env', { loose: true }]
+        ],
+        plugins: [
+          'add-module-exports'
+        ],
         auxiliaryCommentBefore: 'istanbul ignore next'
       },
-      amd: {
-        options: {
-          modules: 'amd'
-        },
-        files: [
-          {
-            expand: true,
-            cwd: 'lib/',
-            src: '**/!(index).js',
-            dest: 'dist/amd/'
-          }
-        ]
-      },
-
       cjs: {
-        options: {
-          modules: 'common'
-        },
         files: [
           {
             cwd: 'lib/',
@@ -75,59 +61,33 @@
         ]
       }
     },
+
     webpack: {
       options: {
         context: __dirname,
-        module: {
-          loaders: [
-            // the optional 'runtime' transformer tells babel to require the runtime instead of inlining it.
-            {
-              test: /\.jsx?$/,
-              exclude: /node_modules/,
-              loader:
-                'babel-loader?optional=runtime&loose=es6.modules&auxiliaryCommentBefore=istanbul%20ignore%20next'
-            }
-          ]
-        },
         output: {
-          path: 'dist/',
           library: 'Handlebars',
+          path: path.join(__dirname, 'dist'),
           libraryTarget: 'umd'
+        },
+        module: {
+          noParse: [ /parser\.js$/ ]
         }
       },
       handlebars: {
-        entry: './lib/handlebars.js',
+        entry: './dist/cjs/handlebars.js',
         output: {
           filename: 'handlebars.js'
         }
       },
       runtime: {
-        entry: './lib/handlebars.runtime.js',
+        entry: './dist/cjs/handlebars.runtime.js',
         output: {
           filename: 'handlebars.runtime.js'
         }
       }
     },
 
-    requirejs: {
-      options: {
-        optimize: 'none',
-        baseUrl: 'dist/amd/'
-      },
-      dist: {
-        options: {
-          name: 'handlebars',
-          out: 'dist/handlebars.amd.js'
-        }
-      },
-      runtime: {
-        options: {
-          name: 'handlebars.runtime',
-          out: 'dist/handlebars.runtime.amd.js'
-        }
-      }
-    },
-
     uglify: {
       options: {
         mangle: true,
@@ -169,10 +129,7 @@
       all: {
         options: {
           build: process.env.TRAVIS_JOB_ID,
-          urls: [
-            'http://localhost:9999/spec/?headless=true',
-            'http://localhost:9999/spec/amd.html?headless=true'
-          ],
+          urls: ['http://localhost:9999/spec/?headless=true'],
           detailedError: true,
           concurrency: 4,
           browsers: [
@@ -198,12 +155,14 @@
           build: process.env.TRAVIS_JOB_ID,
           urls: [
             'http://localhost:9999/spec/umd.html?headless=true',
-            'http://localhost:9999/spec/amd-runtime.html?headless=true',
             'http://localhost:9999/spec/umd-runtime.html?headless=true'
           ],
           detailedError: true,
           concurrency: 2,
-          browsers: [{ browserName: 'chrome' }]
+          browsers: [
+	    { browserName: 'chrome' },
+            { browserName: 'internet explorer', version: 10, platform: 'Windows 8' }
+          ]
         }
       }
     },
@@ -233,7 +192,6 @@
   grunt.loadNpmTasks('grunt-contrib-concat');
   grunt.loadNpmTasks('grunt-contrib-connect');
   grunt.loadNpmTasks('grunt-contrib-copy');
-  grunt.loadNpmTasks('grunt-contrib-requirejs');
   grunt.loadNpmTasks('grunt-contrib-uglify');
   grunt.loadNpmTasks('grunt-contrib-watch');
   grunt.loadNpmTasks('grunt-babel');
@@ -253,7 +211,6 @@
   this.registerTask('globals', ['webpack']);
 
   this.registerTask('release', 'Build final packages', [
-    'amd',
     'uglify',
     'test:min',
     'copy:dist',
@@ -261,8 +218,6 @@
     'copy:cdnjs'
   ]);
 
-  this.registerTask('amd', ['babel:amd', 'requirejs']);
-
   this.registerTask('test', ['test:bin', 'test:cov']);
 
   grunt.registerTask('bench', ['metrics']);
@@ -283,7 +238,6 @@
   ]);
   grunt.registerTask('on-file-change', [
     'build',
-    'amd',
     'concat:tests',
     'test'
   ]);
