Skip to content

Commit 89fb9fd

Browse files
authored
Upgrade webpack to v5 (#7540)
1 parent f497a40 commit 89fb9fd

File tree

9 files changed

+281
-52
lines changed

9 files changed

+281
-52
lines changed

Diff for: config/webpack.test.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
const path = require('path');
1919
const webpack = require('webpack');
20+
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
2021

2122
/**
2223
* A regular expression used to replace Firestore's and Storage's platform-
@@ -28,6 +29,11 @@ const PLATFORM_RE = /^(.*)\/platform\/([^.\/]*)(\.ts)?$/;
2829
module.exports = {
2930
mode: 'development',
3031
devtool: 'source-map',
32+
optimization: {
33+
runtimeChunk: false,
34+
splitChunks: false,
35+
minimize: false
36+
},
3137
module: {
3238
rules: [
3339
{
@@ -98,7 +104,7 @@ module.exports = {
98104
modules: ['node_modules', path.resolve(__dirname, '../../node_modules')],
99105
mainFields: ['browser', 'module', 'main'],
100106
extensions: ['.js', '.ts'],
101-
symlinks: false
107+
symlinks: true
102108
},
103109
plugins: [
104110
new webpack.NormalModuleReplacementPlugin(PLATFORM_RE, resource => {
@@ -108,6 +114,7 @@ module.exports = {
108114
`$1/platform/${targetPlatform}/$2.ts`
109115
);
110116
}),
117+
new NodePolyfillPlugin(),
111118
new webpack.EnvironmentPlugin([
112119
'RTDB_EMULATOR_PORT',
113120
'RTDB_EMULATOR_NAMESPACE'

Diff for: integration/firebase/test/namespace.test.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
* limitations under the License.
1616
*/
1717

18-
import firebase from 'firebase/compat';
18+
import firebase from 'firebase/compat/app';
19+
import 'firebase/compat/auth';
20+
import 'firebase/compat/database';
21+
import 'firebase/compat/storage';
22+
import 'firebase/compat/messaging';
1923
import * as namespaceDefinition from './namespaceDefinition.json';
2024
import validateNamespace from './validator';
2125

Diff for: integration/firestore/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"mocha": "9.2.2",
3232
"ts-loader": "8.4.0",
3333
"typescript": "4.2.2",
34-
"webpack": "4.46.0",
34+
"webpack": "5.76.0",
3535
"webpack-stream": "6.1.2"
3636
}
3737
}

Diff for: package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"size-report": "ts-node-script scripts/size_report/report_binary_size.ts",
4646
"modular-export-size-report": "ts-node-script scripts/size_report/report_modular_export_binary_size.ts",
4747
"api-report": "lerna run --scope @firebase/* api-report",
48-
"postinstall": "yarn --cwd repo-scripts/changelog-generator build",
48+
"postinstall": "patch-package && yarn --cwd repo-scripts/changelog-generator build",
4949
"sa": "ts-node-script repo-scripts/size-analysis/cli.ts",
5050
"api-documenter-devsite": "ts-node-script repo-scripts/api-documenter/src/start.ts",
5151
"format": "ts-node ./scripts/format/format.ts"
@@ -122,7 +122,7 @@
122122
"karma-sourcemap-loader": "0.4.0",
123123
"karma-spec-reporter": "0.0.34",
124124
"karma-summary-reporter": "3.1.1",
125-
"karma-webpack": "4.0.2",
125+
"karma-webpack": "5.0.0",
126126
"lcov-result-merger": "3.1.0",
127127
"lerna": "4.0.0",
128128
"listr": "0.14.3",
@@ -132,9 +132,12 @@
132132
"mkdirp": "1.0.4",
133133
"mocha": "9.2.2",
134134
"mz": "2.7.0",
135+
"node-polyfill-webpack-plugin": "2.0.1",
135136
"npm-run-all": "4.1.5",
136137
"nyc": "15.1.0",
137138
"ora": "5.4.1",
139+
"patch-package": "7.0.0",
140+
"postinstall-postinstall": "2.1.0",
138141
"prettier": "2.8.7",
139142
"protractor": "5.4.2",
140143
"request": "2.88.2",
@@ -151,7 +154,7 @@
151154
"typedoc": "0.16.11",
152155
"typescript": "4.7.4",
153156
"watch": "1.0.2",
154-
"webpack": "4.46.0",
157+
"webpack": "5.76.0",
155158
"yargs": "17.7.1"
156159
}
157160
}

Diff for: packages/auth-compat/test/helpers/helpers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import * as sinon from 'sinon';
1919
import firebase from '@firebase/app-compat';
20+
import '@firebase/auth-compat';
2021
import { Provider } from '@firebase/component';
2122
import '../..';
2223

Diff for: packages/auth/test/helpers/integration/helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import * as sinon from 'sinon';
1919
import { deleteApp, initializeApp } from '@firebase/app';
20-
import { Auth, User } from '../../../src/model/public_types';
20+
import { Auth, User } from '@firebase/auth';
2121

2222
import { getAuth, connectAuthEmulator } from '../../../'; // Use browser OR node dist entrypoint depending on test env.
2323
import { _generateEventId } from '../../../src/core/util/event_id';

Diff for: patches/karma-webpack+5.0.0.patch

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
diff --git a/node_modules/karma-webpack/lib/webpack/plugin.js b/node_modules/karma-webpack/lib/webpack/plugin.js
2+
index 47b993c..3b75a9e 100644
3+
--- a/node_modules/karma-webpack/lib/webpack/plugin.js
4+
+++ b/node_modules/karma-webpack/lib/webpack/plugin.js
5+
@@ -1,4 +1,5 @@
6+
const fs = require('fs');
7+
+const path = require('path');
8+
9+
class KW_WebpackPlugin {
10+
constructor(options) {
11+
@@ -14,9 +15,10 @@ class KW_WebpackPlugin {
12+
// read generated file content and store for karma preprocessor
13+
this.controller.bundlesContent = {};
14+
stats.toJson().assets.forEach((webpackFileObj) => {
15+
- const filePath = `${compiler.options.output.path}/${
16+
+ const filePath = path.resolve(
17+
+ compiler.options.output.path,
18+
webpackFileObj.name
19+
- }`;
20+
+ );
21+
this.controller.bundlesContent[webpackFileObj.name] = fs.readFileSync(
22+
filePath,
23+
'utf-8'

Diff for: repo-scripts/size-analysis/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"rollup-plugin-replace": "2.2.0",
2727
"rollup-plugin-typescript2": "0.31.2",
2828
"@rollup/plugin-virtual": "2.1.0",
29-
"webpack": "4.46.0",
29+
"webpack": "5.76.0",
3030
"@types/webpack": "5.28.0",
3131
"webpack-virtual-modules": "0.5.0",
3232
"child-process-promise": "2.2.1",

0 commit comments

Comments
 (0)