From 871a28360147001710278142de1170b080ea949f Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Wed, 11 Jul 2018 10:16:45 +0200 Subject: [PATCH] Merge pull request #8364 from ahocevar/ie-examples Make examples work in IE11 --- examples/webpack/config.js | 12 ++++++++++++ examples/webpack/example-builder.js | 11 +++++------ package.json | 5 +++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/examples/webpack/config.js b/examples/webpack/config.js index 56ec4351e0..d5db5e4ee8 100644 --- a/examples/webpack/config.js +++ b/examples/webpack/config.js @@ -18,6 +18,18 @@ module.exports = { context: src, target: 'web', entry: entry, + module: { + rules: [{ + use: { + loader: 'buble-loader' + }, + test: /\.js$/, + include: [ + path.join(__dirname, '..', '..', 'src'), + path.join(__dirname, '..') + ] + }] + }, optimization: { runtimeChunk: { name: 'common' diff --git a/examples/webpack/example-builder.js b/examples/webpack/example-builder.js index e4df83ddc8..dd4e299a7e 100644 --- a/examples/webpack/example-builder.js +++ b/examples/webpack/example-builder.js @@ -64,20 +64,20 @@ function createWordIndex(exampleData) { /** * Gets the source for the chunk that matches the jsPath * @param {Object} chunk Chunk. - * @param {string} jsPath Path of the file. + * @param {string} jsName Name of the file. * @return {string} The source. */ -function getJsSource(chunk, jsPath) { +function getJsSource(chunk, jsName) { let jsSource; for (let i = 0, ii = chunk.modules.length; i < ii; ++i) { const module = chunk.modules[i]; if (module.modules) { - jsSource = getJsSource(module, jsPath); + jsSource = getJsSource(module, jsName); if (jsSource) { return jsSource; } } - if (module.identifier == jsPath) { + if (module.identifier.endsWith(jsName)) { return module.source; } } @@ -151,8 +151,7 @@ ExampleBuilder.prototype.render = async function(dir, chunk) { // add in script tag const jsName = `${name}.js`; - const jsPath = path.join(dir, jsName); - let jsSource = getJsSource(chunk, jsPath); + let jsSource = getJsSource(chunk, path.join('.', jsName)); jsSource = jsSource.replace(/'\.\.\/src\//g, '\''); if (data.cloak) { for (const entry of data.cloak) { diff --git a/package.json b/package.json index 2b2cfd50f7..18862958fa 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "devDependencies": { "babel-core": "^6.26.3", "babel-plugin-jsdoc-closure": "1.5.1", + "buble-loader": "^0.5.1", "chaikin-smooth": "^1.0.4", "clean-css-cli": "4.1.11", "copy-webpack-plugin": "^4.4.1", @@ -82,8 +83,8 @@ "uglifyjs-webpack-plugin": "^1.2.5", "url-polyfill": "^1.0.13", "walk": "^2.3.9", - "webpack": "4.12.1", - "webpack-cli": "^3.0.3", + "webpack": "4.15.1", + "webpack-cli": "^3.0.8", "webpack-dev-server": "^3.1.4" }, "eslintConfig": {