From 0d24bde8069b0cc43e1fb745c168a40ec4a52217 Mon Sep 17 00:00:00 2001 From: Janicklas Ralph James Date: Mon, 23 Sep 2019 15:12:31 -0700 Subject: [PATCH 01/37] Adding native-url package --- packages/next/build/webpack-config.ts | 11 +++++++++++ packages/next/client/polyfill.js | 1 + packages/next/package.json | 2 ++ packages/next/pages/_document.tsx | 10 ++++++++++ yarn.lock | 12 ++++++++++++ 5 files changed, 36 insertions(+) create mode 100644 packages/next/client/polyfill.js diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index e567f0c0292fd..764465fb5d85d 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -16,6 +16,7 @@ import { fileExists } from '../lib/file-exists' import { resolveRequest } from '../lib/resolve-request' import { CLIENT_STATIC_FILES_RUNTIME_MAIN, + CLIENT_STATIC_FILES_PATH, CLIENT_STATIC_FILES_RUNTIME_WEBPACK, REACT_LOADABLE_MANIFEST, SERVER_DIRECTORY, @@ -111,6 +112,11 @@ export default async function getBaseWebpackConfig( dev ? `next-dev.js` : 'next.js' ) ), + [path.join( + CLIENT_STATIC_FILES_PATH, + buildId, + 'polyfill.js' + )]: path.join(NEXT_PROJECT_ROOT_DIST_CLIENT, 'polyfill.js'), } : undefined @@ -156,6 +162,11 @@ export default async function getBaseWebpackConfig( next: NEXT_PROJECT_ROOT, [PAGES_DIR_ALIAS]: path.join(dir, 'pages'), [DOT_NEXT_ALIAS]: distDir, + ...(!isServer + ? { + url: 'native-url', + } + : {}), }, mainFields: isServer ? ['main', 'module'] : ['browser', 'module', 'main'], plugins: [PnpWebpackPlugin], diff --git a/packages/next/client/polyfill.js b/packages/next/client/polyfill.js new file mode 100644 index 0000000000000..0fcabf84e8fd9 --- /dev/null +++ b/packages/next/client/polyfill.js @@ -0,0 +1 @@ +import 'url-polyfill' diff --git a/packages/next/package.json b/packages/next/package.json index 9a1fbc81c7a21..fb3fd7b7fd239 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -99,6 +99,7 @@ "loader-utils": "1.2.3", "mini-css-extract-plugin": "0.8.0", "mkdirp": "0.5.1", + "native-url": "0.1.1", "node-fetch": "2.6.0", "ora": "3.4.0", "path-to-regexp": "2.1.0", @@ -120,6 +121,7 @@ "terser": "4.0.0", "unfetch": "4.1.0", "url": "0.11.0", + "url-polyfill": "1.1.7", "watchpack": "2.0.0-beta.5", "webpack": "4.39.0", "webpack-dev-middleware": "3.7.0", diff --git a/packages/next/pages/_document.tsx b/packages/next/pages/_document.tsx index d2401fa75194b..3121eb5876ce5 100644 --- a/packages/next/pages/_document.tsx +++ b/packages/next/pages/_document.tsx @@ -749,6 +749,16 @@ export class NextScript extends Component { }} /> ) : null} +