From 831359ce57770fc11234c3aded6b932eff146e7d Mon Sep 17 00:00:00 2001 From: kpdecker Date: Mon, 14 Dec 2015 02:22:30 -0600 Subject: [PATCH] Remove amd files from the build Users can utilize the UMD library if they are still using require.js and if they need to have specific modules, they can consume the cjs or es6 modules via webpack or similar. Fix for #1096 --- FAQ.md | 10 +--- Gruntfile.js | 47 ++-------------- package.json | 3 +- spec/amd-runtime.html | 105 ----------------------------------- spec/amd.html | 125 ------------------------------------------ 5 files changed, 7 insertions(+), 283 deletions(-) delete mode 100644 spec/amd-runtime.html delete mode 100644 spec/amd.html diff --git a/FAQ.md b/FAQ.md index 108e839af..49462856d 100644 --- a/FAQ.md +++ b/FAQ.md @@ -47,14 +47,6 @@ Should these match, please file an issue with us, per our [issue filing guidelines](https://github.com/wycats/handlebars.js/blob/master/CONTRIBUTING.md#reporting-issues). -1. Why doesn't IE like the `default` name in the AMD module? - - Some browsers such as particular versions of IE treat `default` as a reserved word in JavaScript source files. To safely use this you need to reference this via the `Handlebars['default']` lookup method. This is an unfortunate side effect of the shims necessary to backport the Handlebars ES6 code to all current browsers. - 1. How do I load the runtime library when using AMD? - There are two options for loading under AMD environments. The first is to use the `handlebars.runtime.amd.js` file. This may require a [path mapping](https://github.com/wycats/handlebars.js/blob/master/spec/amd-runtime.html#L31) as well as access via the `default` field. - - The other option is to load the `handlebars.runtime.js` UMD build, which might not require path configuration and exposes the library as both the module root and the `default` field for compatibility. - - If not using ES6 transpilers or accessing submodules in the build the former option should be sufficient for most use cases. + The `handlebars.runtime.js` file includes a UMD build, which exposes the library as both the module root and the `default` field for compatibility. diff --git a/Gruntfile.js b/Gruntfile.js index ce85e9a4a..deb06fc91 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -44,23 +44,6 @@ module.exports = function(grunt) { }, babel: { - options: { - sourceMaps: 'inline', - loose: ['es6.modules'], - auxiliaryCommentBefore: 'istanbul ignore next' - }, - amd: { - options: { - modules: 'amd' - }, - files: [{ - expand: true, - cwd: 'lib/', - src: '**/!(index).js', - dest: 'dist/amd/' - }] - }, - cjs: { options: { modules: 'common' @@ -102,25 +85,6 @@ module.exports = function(grunt) { } }, - 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, @@ -160,7 +124,7 @@ module.exports = function(grunt) { 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: [ @@ -176,11 +140,12 @@ module.exports = function(grunt) { sanity: { options: { 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'], + urls: ['http://localhost:9999/spec/umd.html?headless=true', 'http://localhost:9999/spec/umd-runtime.html?headless=true'], detailedError: true, concurrency: 2, browsers: [ - {browserName: 'chrome'} + {browserName: 'chrome'}, + {browserName: 'internet explorer', version: 10, platform: 'Windows 8'} ] } } @@ -205,19 +170,17 @@ module.exports = function(grunt) { 'node', 'globals']); - this.registerTask('amd', ['babel:amd', 'requirejs']); this.registerTask('node', ['babel:cjs']); this.registerTask('globals', ['webpack']); this.registerTask('tests', ['concat:tests']); - this.registerTask('release', 'Build final packages', ['eslint', 'amd', 'uglify', 'test:min', 'copy:dist', 'copy:components', 'copy:cdnjs']); + this.registerTask('release', 'Build final packages', ['eslint', 'uglify', 'test:min', 'copy:dist', 'copy:components', 'copy:cdnjs']); // Load tasks from npm grunt.loadNpmTasks('grunt-contrib-clean'); 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'); diff --git a/package.json b/package.json index 4ee3aede1..70390ff5a 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "grunt-contrib-concat": "0.x", "grunt-contrib-connect": "0.x", "grunt-contrib-copy": "0.x", - "grunt-contrib-requirejs": "0.x", "grunt-contrib-uglify": "0.x", "grunt-contrib-watch": "0.x", "grunt-eslint": "^17.1.0", @@ -68,7 +67,7 @@ "jspm": { "main": "handlebars", "directories": { - "lib": "dist/amd" + "lib": "dist/cjs" }, "buildConfig": { "minify": true diff --git a/spec/amd-runtime.html b/spec/amd-runtime.html deleted file mode 100644 index 7cc64f190..000000000 --- a/spec/amd-runtime.html +++ /dev/null @@ -1,105 +0,0 @@ - - - Mocha - - - - - - - - - - - - - - - - - - -
- - diff --git a/spec/amd.html b/spec/amd.html deleted file mode 100644 index 1149dc706..000000000 --- a/spec/amd.html +++ /dev/null @@ -1,125 +0,0 @@ - - - - Mocha - - - - - - - - - - - - - - - - - - -
- -