diff --git a/build/chunk-preload-plugin.js b/build/chunk-preload-plugin.js deleted file mode 100644 index 0beb321b..00000000 --- a/build/chunk-preload-plugin.js +++ /dev/null @@ -1,72 +0,0 @@ -/** Copyright (c) 2018 Uber Technologies, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow - */ - -/* eslint-env node */ - -/** - * Webpack plugin for being able to mark async chunks as being already preloaded - * This is meant for the client and ensures that webpack only requests for chunks - * once. This is necessary because we automatically inline scripts for async chunks - * that are used during the server side render. We use Object.defineProperty to make - * the values lazy so `new Promise` is not executed until the promise polyfill is loaded. - */ - -const Template = require('webpack/lib/Template'); - -class ChunkPreloadPlugin { - apply(compiler /*: any */) { - compiler.hooks.compilation.tap('ChunkPreloadPlugin', function(compilation) { - compilation.mainTemplate.hooks.localVars.tap( - 'ChunkPreloadPlugin', - function(source) { - var buf = [source]; - buf.push(''); - buf.push('// chunk preloading'); - buf.push( - ` - if (window.__PRELOADED_CHUNKS__) { - window.__PRELOADED_CHUNKS__.forEach(function(chunkId) { - var result; - Object.defineProperty(installedChunks, chunkId, { - get: function() { - if (result) { - return result; - } - var promise = new Promise(function(resolve, reject) { - result = [resolve, reject]; - }); - result[2] = promise; - return result; - } - }); - }); - } - - var rejectChunkPreload = function(chunkId) { - var chunk = installedChunks[chunkId]; - if(chunk !== 0) { - if(chunk) chunk[1](new Error('Loading chunk ' + chunkId + ' failed.')); - installedChunks[chunkId] = undefined; - } - } - - window.__HANDLE_ERROR = rejectChunkPreload; - - if (window.__UNHANDLED_ERRORS__) { - window.__UNHANDLED_ERRORS__.forEach(rejectChunkPreload); - } - ` - ); - return Template.asString(buf); - } - ); - }); - } -} - -module.exports = ChunkPreloadPlugin; diff --git a/build/compiler.js b/build/compiler.js index 11034e2c..f0319fad 100644 --- a/build/compiler.js +++ b/build/compiler.js @@ -26,7 +26,6 @@ const resolveFrom = require('resolve-from'); const AssetsManifestPlugin = require('./file-loader-asset-manifest-plugin'); const ClientSourceMapPlugin = require('./client-source-map-plugin'); -const ChunkPreloadPlugin = require('./chunk-preload-plugin'); const ChunkModuleManifestPlugin = require('./chunk-module-manifest-plugin'); const chunkModuleManifest = require('./chunk-module-manifest'); const InstrumentedImportDependencyTemplatePlugin = require('./instrumented-import-dependency-template-plugin'); @@ -447,9 +446,6 @@ function getConfig({target, env, dir, watch, cover}) { env === 'production' && target === 'web' && new webpack.HashedModuleIdsPlugin(), - target === 'web' && env !== 'test' && new ChunkPreloadPlugin(), - // TODO(#11): What do we do for client-side error reporting in the service worker? - // Do we add in reporting code to the sw? Should we map stack traces on the server? target === 'web' && new ClientSourceMapPlugin(), target === 'web' && new SyncChunkIdsPlugin(), target === 'web' && diff --git a/package.json b/package.json index 0deeb78a..9ec73a16 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "eslint-plugin-prettier": "2.6.2", "eslint-plugin-react": "^7.10.0", "flow-bin": "0.77.0", - "fusion-core": "^1.4.1", + "fusion-core": "^1.5.0-beta.0", "fusion-plugin-i18n-react": "^1.0.4", "fusion-plugin-react-router": "^1.1.3", "fusion-react": "^1.1.0", @@ -104,7 +104,7 @@ }, "peerDependencies": { "enzyme": "^3.3.0", - "fusion-core": "^1.3.1", + "fusion-core": "^1.5.0-beta.0", "fusion-tokens": "^1.0.4" }, "engines": { diff --git a/yarn.lock b/yarn.lock index 4feb97b8..1f8c7fa1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3335,9 +3335,9 @@ functional-red-black-tree@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" -fusion-core@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/fusion-core/-/fusion-core-1.4.1.tgz#22daeddeefa3125b056cdcccd9c6dd486d7f032e" +fusion-core@^1.5.0-beta.0: + version "1.5.0-beta.0" + resolved "https://registry.yarnpkg.com/fusion-core/-/fusion-core-1.5.0-beta.0.tgz#30c36bdd75edef51bd828008bc7d11e61c8ac5e1" dependencies: koa "^2.4.1" koa-compose "^4.0.0"