From def0703e71f8ee2400e94f02f1e425ac3ec6ac64 Mon Sep 17 00:00:00 2001 From: Jan Nicklas Date: Wed, 23 Mar 2016 11:13:38 +0100 Subject: [PATCH] Add inline tests for webpack 2 --- examples/{rebuild.js => build-examples.js} | 1 - .../inline/dist/{ => webpack-1}/bundle.js | 0 .../inline/dist/{ => webpack-1}/favicon.ico | Bin .../inline/dist/{ => webpack-1}/index.html | 0 .../inline/dist/{ => webpack-1}/styles.css | 0 examples/inline/dist/webpack-2/bundle.js | 60 +++++++++++++++++ examples/inline/dist/webpack-2/favicon.ico | Bin 0 -> 766 bytes examples/inline/dist/webpack-2/index.html | 62 ++++++++++++++++++ examples/inline/dist/webpack-2/styles.css | 3 + examples/inline/webpack.config.js | 4 +- lib/chunksorter.js | 4 +- package.json | 2 +- spec/ExampleSpec.js | 4 ++ 13 files changed, 135 insertions(+), 5 deletions(-) rename examples/{rebuild.js => build-examples.js} (99%) rename examples/inline/dist/{ => webpack-1}/bundle.js (100%) rename examples/inline/dist/{ => webpack-1}/favicon.ico (100%) rename examples/inline/dist/{ => webpack-1}/index.html (100%) rename examples/inline/dist/{ => webpack-1}/styles.css (100%) create mode 100644 examples/inline/dist/webpack-2/bundle.js create mode 100644 examples/inline/dist/webpack-2/favicon.ico create mode 100644 examples/inline/dist/webpack-2/index.html create mode 100644 examples/inline/dist/webpack-2/styles.css diff --git a/examples/rebuild.js b/examples/build-examples.js similarity index 99% rename from examples/rebuild.js rename to examples/build-examples.js index 2d98200..563224c 100644 --- a/examples/rebuild.js +++ b/examples/build-examples.js @@ -4,7 +4,6 @@ * You could do the same by going into each example and execute * `webpack` */ - var webpackMajorVersion = require('webpack/package.json').version.split('.')[0]; var fs = require('fs'); diff --git a/examples/inline/dist/bundle.js b/examples/inline/dist/webpack-1/bundle.js similarity index 100% rename from examples/inline/dist/bundle.js rename to examples/inline/dist/webpack-1/bundle.js diff --git a/examples/inline/dist/favicon.ico b/examples/inline/dist/webpack-1/favicon.ico similarity index 100% rename from examples/inline/dist/favicon.ico rename to examples/inline/dist/webpack-1/favicon.ico diff --git a/examples/inline/dist/index.html b/examples/inline/dist/webpack-1/index.html similarity index 100% rename from examples/inline/dist/index.html rename to examples/inline/dist/webpack-1/index.html diff --git a/examples/inline/dist/styles.css b/examples/inline/dist/webpack-1/styles.css similarity index 100% rename from examples/inline/dist/styles.css rename to examples/inline/dist/webpack-1/styles.css diff --git a/examples/inline/dist/webpack-2/bundle.js b/examples/inline/dist/webpack-2/bundle.js new file mode 100644 index 0000000..f5d58df --- /dev/null +++ b/examples/inline/dist/webpack-2/bundle.js @@ -0,0 +1,60 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].e; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ e: {}, +/******/ i: moduleId, +/******/ l: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.e, module, module.e, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.l = true; + +/******/ // Return the exports of the module +/******/ return module.e; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 1); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports) { + + // removed by extract-text-webpack-plugin + +/***/ }, +/* 1 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + __webpack_require__(0); + + console.log('Hello World'); + + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/examples/inline/dist/webpack-2/favicon.ico b/examples/inline/dist/webpack-2/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..be74abd69ad6a32de7375df13cab9354798e328f GIT binary patch literal 766 zcmc(dze~eV5XUd2fg&jH87YDYDQKxq1{4b-_ydP-wqS9vgGh17QXQQAwOE{VaBvi* zmu^z9t({y-&1ey8Y_x;?x+`BviV9;aRjMgZ8M*!jgkRrFqSI9;F zHyfX@Az|AvVmn~YWWZP`0&JWEY~BFm?*Vq}VD7&_%x%MP$p`D`4JMC!K|B7pt?Mmp zUJAB7rxMXS6=!P+AtLU9V)J#61WPxwipRXCHO{BJ`l{m53#=t97a!znv~vfmr|AaP zRGIT7#0FyJy3Z*hL{GQp-0TRhX8UzZ)+>%?mK0^goaX4Q;xJade demo \ No newline at end of file diff --git a/examples/inline/dist/webpack-2/styles.css b/examples/inline/dist/webpack-2/styles.css new file mode 100644 index 0000000..232a2cd --- /dev/null +++ b/examples/inline/dist/webpack-2/styles.css @@ -0,0 +1,3 @@ +body { + background: snow; +} \ No newline at end of file diff --git a/examples/inline/webpack.config.js b/examples/inline/webpack.config.js index 581a2ad..f46ca6a 100755 --- a/examples/inline/webpack.config.js +++ b/examples/inline/webpack.config.js @@ -1,9 +1,11 @@ var HtmlWebpackPlugin = require('../..'); var ExtractTextPlugin = require('extract-text-webpack-plugin'); +var webpackMajorVersion = require('webpack/package.json').version.split('.')[0]; + module.exports = { entry: './example.js', output: { - path: __dirname + '/dist', + path: __dirname + '/dist/webpack-' + webpackMajorVersion, publicPath: '', filename: 'bundle.js' }, diff --git a/lib/chunksorter.js b/lib/chunksorter.js index 16a73e1..fc41ae5 100644 --- a/lib/chunksorter.js +++ b/lib/chunksorter.js @@ -82,8 +82,8 @@ module.exports.none = function (chunks) { */ module.exports.auto = module.exports.id; -// In webpack 2 the ids are fliped around. -// Therefore the id sort is broken +// In webpack 2 the ids have been flipped. +// Therefore the id sort doesn't work the same way as it did for webpack 1 // Luckily the dependency sort is working as expected if (require('webpack/package.json').version.split('.')[0] === '2') { module.exports.auto = module.exports.dependency; diff --git a/package.json b/package.json index 856507d..0b69db3 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "scripts": { "prepublish": "npm run test", "pretest": "semistandard", - "recompile": "node examples/rebuild.js", + "build-examples": "node examples/build-examples.js", "test": "jasmine" }, "repository": { diff --git a/spec/ExampleSpec.js b/spec/ExampleSpec.js index 192f540..b40a571 100644 --- a/spec/ExampleSpec.js +++ b/spec/ExampleSpec.js @@ -70,6 +70,10 @@ describe('HtmlWebpackPlugin Examples', function () { runExample('html-loader', done); }); + it('inline example', function (done) { + runExample('inline', done); + }); + it('jade-loader example', function (done) { runExample('jade-loader', done); });