Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
refactor: add webpack >= v4.0.0 support (#3)
  • Loading branch information
Graham42 authored and michael-ciniawsky committed Feb 16, 2018
1 parent f663339 commit a8a8c2b
Show file tree
Hide file tree
Showing 57 changed files with 2,647 additions and 183 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
Expand Up @@ -7,12 +7,22 @@ env:
- WEBPACK_VERSION=1 EXTRACT_PLUGIN_VERSION=1
- WEBPACK_VERSION=2 EXTRACT_PLUGIN_VERSION=2
- WEBPACK_VERSION=3 EXTRACT_PLUGIN_VERSION=3.0.0-beta.3
- WEBPACK_VERSION=4.0.0-beta.1 EXTRACT_PLUGIN_VERSION=4.0.0-alpha.0
before_install:
- stty columns 120
install:
- npm install --ignore-scripts
- npm rm webpack
- npm rm extract-text-webpack-plugin
- npm install webpack@$WEBPACK_VERSION extract-text-webpack-plugin@$EXTRACT_PLUGIN_VERSION --ignore-scripts || true
matrix:
exclude:
- env: WEBPACK_VERSION=4.0.0-beta.1 EXTRACT_PLUGIN_VERSION=4.0.0-alpha.0
node_js: "4"
- env: WEBPACK_VERSION=4.0.0-beta.1 EXTRACT_PLUGIN_VERSION=4.0.0-alpha.0
node_js: "5"
include:
- env: WEBPACK_VERSION=4.0.0-beta.1 EXTRACT_PLUGIN_VERSION=4.0.0-alpha.0
node_js: "8"
script:
- npm test
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions examples/appcache/dist/webpack-4/bundle.js
@@ -0,0 +1,92 @@
/******/ (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].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {

__webpack_require__(4);
var h1 = document.createElement('h1');
h1.innerHTML = 'Hello world!';
document.body.appendChild(h1);


/***/ }),
/* 1 */,
/* 2 */,
/* 3 */,
/* 4 */
/***/ (function(module, exports) {

// removed by extract-text-webpack-plugin

/***/ })
/******/ ]);
1 change: 1 addition & 0 deletions examples/appcache/dist/webpack-4/index.html
@@ -0,0 +1 @@
<!doctype html><html lang="en" manifest="manifest.appcache"><head><meta charset="utf-8"><title>Example template</title><meta name="viewport" content="width=device-width,initial-scale=1"><link href="styles.css" rel="stylesheet"></head><body><img src="0714810ae3fb211173e2964249507195.png"><script type="text/javascript" src="bundle.js"></script></body></html>
9 changes: 9 additions & 0 deletions examples/appcache/dist/webpack-4/manifest.appcache
@@ -0,0 +1,9 @@
CACHE MANIFEST
# 95a89258cd32fe3f01e3

0714810ae3fb211173e2964249507195.png
bundle.js
styles.css

NETWORK:
*
3 changes: 3 additions & 0 deletions examples/appcache/dist/webpack-4/styles.css
@@ -0,0 +1,3 @@
body {
background: snow;
}
17 changes: 16 additions & 1 deletion examples/build-examples.js
Expand Up @@ -30,8 +30,23 @@ examples.forEach(function (exampleName) {
var examplePath = path.join(__dirname, exampleName);
var configFile = path.join(examplePath, 'webpack.config.js');

var config = require(configFile);
if (webpackMajorVersion === '4') {
config.plugins.unshift(new webpack.LoaderOptionsPlugin({
options: {
context: process.cwd() // or the same value as `context`
}
}));
config.mode = 'production';
config.optimization = { minimizer: [] };
if (config.module && config.module.loaders) {
config.module.rules = config.module.loaders;
delete config.module.loaders;
}
}

rimraf.sync(path.join(examplePath, 'dist', 'webpack-' + webpackMajorVersion));
webpack(require(configFile), function (err, stats) {
webpack(config, function (err, stats) {
if (err) {
console.error(err.stack || err);
if (err.details) {
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions examples/custom-template/dist/webpack-4/bundle.js
@@ -0,0 +1,92 @@
/******/ (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].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {

__webpack_require__(4);
var h1 = document.createElement('h1');
h1.innerHTML = 'Hello world!';
document.body.appendChild(h1);


/***/ }),
/* 1 */,
/* 2 */,
/* 3 */,
/* 4 */
/***/ (function(module, exports) {

// removed by extract-text-webpack-plugin

/***/ })
/******/ ]);
12 changes: 12 additions & 0 deletions examples/custom-template/dist/webpack-4/index.html
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Webpack App</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="styles.css" rel="stylesheet"></head>
<body>
<h2>Partial</h2>
<img src="0714810ae3fb211173e2964249507195.png">
<script type="text/javascript" src="bundle.js"></script></body>
</html>
3 changes: 3 additions & 0 deletions examples/custom-template/dist/webpack-4/styles.css
@@ -0,0 +1,3 @@
body {
background: snow;
}

0 comments on commit a8a8c2b

Please sign in to comment.