From c6c1f9fd183ea4d30d2cc6a795ebe2159d438e36 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Wed, 24 Apr 2024 13:11:48 -0700 Subject: [PATCH 1/3] convert webchannel-wrapper package to use rollup --- .../bloom-blob/package.json | 5 +- packages/webchannel-wrapper/empty.js | 7 ++ packages/webchannel-wrapper/gulpfile.js | 81 ------------------ packages/webchannel-wrapper/package.json | 20 ++--- packages/webchannel-wrapper/rollup.config.js | 82 +++++++++++++++++++ packages/webchannel-wrapper/tsconfig.json | 3 +- .../webchannel-blob/package.json | 5 +- yarn.lock | 16 ---- 8 files changed, 107 insertions(+), 112 deletions(-) create mode 100644 packages/webchannel-wrapper/empty.js delete mode 100644 packages/webchannel-wrapper/gulpfile.js create mode 100644 packages/webchannel-wrapper/rollup.config.js diff --git a/packages/webchannel-wrapper/bloom-blob/package.json b/packages/webchannel-wrapper/bloom-blob/package.json index 9bb95f7bb48..956333e7cf2 100644 --- a/packages/webchannel-wrapper/bloom-blob/package.json +++ b/packages/webchannel-wrapper/bloom-blob/package.json @@ -1,8 +1,9 @@ { "name": "@firebase/webchannel-wrapper/bloom-blob", "description": "Bloom filter related code from the Closure library.", - "browser": "../dist/bloom-blob/bloom_blob_es2018.js", - "module": "../dist/bloom-blob/bloom_blob_es2018.js", + "main": "../dist/bloom-blob/bloom_blob_es2018.js", + "browser": "../dist/bloom-blob/esm/bloom_blob_es2018.js", + "module": "../dist/bloom-blob/esm/bloom_blob_es2018.js", "esm5": "../dist/bloom-blob/bloom_blob_es5.js", "typings": "../dist/bloom-blob/bloom_blob_types.d.ts" } diff --git a/packages/webchannel-wrapper/empty.js b/packages/webchannel-wrapper/empty.js new file mode 100644 index 00000000000..c4f021dd238 --- /dev/null +++ b/packages/webchannel-wrapper/empty.js @@ -0,0 +1,7 @@ +/** + * This package has no main entry point and only allows imports from its + * two subpaths. This file is provided for the top-level package.json + * "main" field to point to. + */ + +export default {}; diff --git a/packages/webchannel-wrapper/gulpfile.js b/packages/webchannel-wrapper/gulpfile.js deleted file mode 100644 index 0d392331059..00000000000 --- a/packages/webchannel-wrapper/gulpfile.js +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const gulp = require('gulp'); -const concat = require('gulp-concat'); -const closureBlobsDir = '../../node_modules/closure-net/firebase/'; - -// A task to distribute bloom blobs into 'dist' -gulp.task('distributeBloomBlobs', () => { - return gulp - .src(closureBlobsDir + 'bloom_blob_*') - .pipe(gulp.dest('dist/bloom-blob/')); -}); - -// A task to distribute bloom blobs into 'dist' -gulp.task('distributeWebChannelBlobs', () => { - return gulp - .src(closureBlobsDir + 'webchannel_blob_*') - .pipe(gulp.dest('dist/webchannel-blob/')); -}); - -// A task to concatenate typings of all blobs into 'dist' -gulp.task('aggregateTypings', () => { - return gulp - .src([ - closureBlobsDir + 'bloom_blob_types.d.ts', - closureBlobsDir + 'webchannel_blob_types.d.ts' - ]) - .pipe(concat('types.d.ts')) - .pipe(gulp.dest('dist/')); -}); - -// A task to concatenate all blobs into one file in 'dist'. -// This is only used to report the total size of this package. -gulp.task( - 'aggregateBlobs', - gulp.parallel( - function () { - return gulp - .src([ - closureBlobsDir + 'bloom_blob_es2018.js', - closureBlobsDir + 'webchannel_blob_es2018.js' - ]) - .pipe(concat('index.js')) - .pipe(gulp.dest('dist/')); - }, - function () { - return gulp - .src([ - closureBlobsDir + 'bloom_blob_es5.js', - closureBlobsDir + 'webchannel_blob_es5.js' - ]) - .pipe(concat('index.esm.js')) - .pipe(gulp.dest('dist/')); - } - ) -); - -gulp.task( - 'default', - gulp.series( - 'distributeBloomBlobs', - 'distributeWebChannelBlobs', - 'aggregateTypings', - 'aggregateBlobs' - ) -); diff --git a/packages/webchannel-wrapper/package.json b/packages/webchannel-wrapper/package.json index 8793efeee20..6ee1f5867b1 100644 --- a/packages/webchannel-wrapper/package.json +++ b/packages/webchannel-wrapper/package.json @@ -3,17 +3,19 @@ "version": "0.10.7", "description": "A wrapper of the webchannel packages from closure-library for use outside of a closure compiled application", "author": "Firebase (https://firebase.google.com/)", - "main": "dist/index.js", - "module": "dist/index.js", - "esm5": "dist/index.esm.js", + "main": "empty.js", "exports": { "./webchannel-blob": { "types": "./dist/webchannel-blob/webchannel_blob_types.d.ts", - "default": "./dist/webchannel-blob/webchannel_blob_es2018.js" + "require": "./dist/webchannel-blob/webchannel_blob_es2018.js", + "esm5": "./dist/webchannel-blob/webchannel_blob_es5.js", + "default": "./dist/webchannel-blob/esm/webchannel_blob_es2018.js" }, "./bloom-blob": { "types": "./dist/bloom-blob/bloom_blob_types.d.ts", - "default": "./dist/bloom-blob/bloom_blob_es2018.js" + "require": "./dist/bloom-blob/bloom_blob_es2018.js", + "es5": "./dist/bloom-blob/bloom_blob_es5.js", + "default": "./dist/bloom-blob/esm/bloom_blob_es2018.js" }, "./package.json": "./package.json" }, @@ -24,7 +26,7 @@ ], "scripts": { "dev": "watch 'yarn build' src", - "build": "gulp", + "build": "rollup -c", "test": "echo 'No test suite for webchannel-wrapper'", "test:ci": "echo 'No test suite for webchannel-wrapper'" }, @@ -32,10 +34,8 @@ "devDependencies": { "closure-net": "git+https://github.com/google/closure-net.git#9844d60", "@rollup/plugin-commonjs": "21.1.0", - "gulp": "4.0.2", - "gulp-concat": "2.6.1", - "gulp-sourcemaps": "3.0.0", "rollup": "2.79.1", + "rollup-plugin-copy": "3.5.0", "rollup-plugin-sourcemaps": "0.6.3", "rollup-plugin-typescript2": "0.31.2", "typescript": "4.7.4" @@ -45,7 +45,7 @@ "type": "git", "url": "git+https://github.com/firebase/firebase-js-sdk.git" }, - "typings": "./dist/types.d.ts", + "typings": "./dist/webchannel-blob/webchannel_blob_types.d.ts", "bugs": { "url": "https://github.com/firebase/firebase-js-sdk/issues" } diff --git a/packages/webchannel-wrapper/rollup.config.js b/packages/webchannel-wrapper/rollup.config.js new file mode 100644 index 00000000000..e3a45fac8e8 --- /dev/null +++ b/packages/webchannel-wrapper/rollup.config.js @@ -0,0 +1,82 @@ +/** + * @license + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { join } from 'path'; +import copy from 'rollup-plugin-copy'; +import commonjs from '@rollup/plugin-commonjs'; +import typescriptPlugin from 'rollup-plugin-typescript2'; +import typescript from 'typescript'; +import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; +import pkg from './package.json'; + +const closureBlobsDir = '../../node_modules/closure-net/firebase/'; + +const deps = [ + ...Object.keys(Object.assign({}, pkg.peerDependencies, pkg.dependencies)) +]; + +const es2017BuildPlugins = [ + copy({ + targets: [ + { src: join(closureBlobsDir, 'webchannel_blob_*.*'), dest: 'dist/webchannel-blob'}, + { src: join(closureBlobsDir, 'bloom_blob_*.*'), dest: 'dist/bloom-blob'}, + ] + }), + typescriptPlugin({ + typescript, + tsconfigOverride: { + compilerOptions: { + target: 'es2017' + } + } + }), + commonjs() +]; + +/** + * ESM builds + */ +const esm2017Builds = [ + { + input: join(closureBlobsDir, 'webchannel_blob_es2018.js'), + output: { + file: pkg.exports['./webchannel-blob'].default, + format: 'es', + sourcemap: true + }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...es2017BuildPlugins, + emitModulePackageFile() + ] + }, + { + input: join(closureBlobsDir, 'bloom_blob_es2018.js'), + output: { + file: pkg.exports['./bloom-blob'].default, + format: 'es', + sourcemap: true + }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...es2017BuildPlugins, + emitModulePackageFile() + ] + } +]; + +export default esm2017Builds; diff --git a/packages/webchannel-wrapper/tsconfig.json b/packages/webchannel-wrapper/tsconfig.json index a777c9d54b7..23e05a91330 100644 --- a/packages/webchannel-wrapper/tsconfig.json +++ b/packages/webchannel-wrapper/tsconfig.json @@ -4,5 +4,6 @@ "declaration": false, "outDir": "dist", "downlevelIteration": true, - } + }, + "include": ["../../node_modules/closure-net/firebase"] } diff --git a/packages/webchannel-wrapper/webchannel-blob/package.json b/packages/webchannel-wrapper/webchannel-blob/package.json index 8b7a532ed03..cb339b82557 100644 --- a/packages/webchannel-wrapper/webchannel-blob/package.json +++ b/packages/webchannel-wrapper/webchannel-blob/package.json @@ -1,8 +1,9 @@ { "name": "@firebase/webchannel-wrapper/webchannel-blob", "description": "Webchannel related code from the Closure library.", - "browser": "../dist/webchannel-blob/webchannel_blob_es2018.js", - "module": "../dist/webchannel-blob/webchannel_blob_es2018.js", + "main": "../dist/webchannel-blob/webchannel_blob_es2018.js", + "browser": "../dist/webchannel-blob/esm/webchannel_blob_es2018.js", + "module": "../dist/webchannel-blob/esm/webchannel_blob_es2018.js", "esm5": "../dist/webchannel-blob/webchannel_blob_es5.js", "typings": "../dist/webchannel-blob/webchannel_blob_types.d.ts" } diff --git a/yarn.lock b/yarn.lock index 4a49e13cf05..1163a54fdb9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6127,13 +6127,6 @@ concat-stream@^2.0.0: readable-stream "^3.0.2" typedarray "^0.0.6" -concat-with-sourcemaps@^1.0.0: - version "1.1.0" - resolved "https://registry.npmjs.org/concat-with-sourcemaps/-/concat-with-sourcemaps-1.1.0.tgz#d4ea93f05ae25790951b99e7b3b09e3908a4082e" - integrity sha512-4gEjHJFT9e+2W/77h/DS5SGUgwDaOwprX8L/gl5+3ixnzkVJJsZWDSelmN3Oilw3LNDZjZV0yqH1hLG3k6nghg== - dependencies: - source-map "^0.6.1" - config-chain@^1.1.11, config-chain@^1.1.12: version "1.1.13" resolved "https://registry.npmjs.org/config-chain/-/config-chain-1.1.13.tgz" @@ -9330,15 +9323,6 @@ gulp-cli@^2.2.0: v8flags "^3.2.0" yargs "^7.1.0" -gulp-concat@2.6.1: - version "2.6.1" - resolved "https://registry.npmjs.org/gulp-concat/-/gulp-concat-2.6.1.tgz#633d16c95d88504628ad02665663cee5a4793353" - integrity sha512-a2scActrQrDBpBbR3WUZGyGS1JEPLg5PZJdIa7/Bi3GuKAmPYDK6SFhy/NZq5R8KsKKFvtfR0fakbUCcKGCCjg== - dependencies: - concat-with-sourcemaps "^1.0.0" - through2 "^2.0.0" - vinyl "^2.0.0" - gulp-filter@7.0.0: version "7.0.0" resolved "https://registry.npmjs.org/gulp-filter/-/gulp-filter-7.0.0.tgz" From 1f64d7d1462c1c63f9aabba034c53fa11eeb76d8 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Wed, 24 Apr 2024 13:23:25 -0700 Subject: [PATCH 2/3] clean up rollup config --- packages/webchannel-wrapper/rollup.config.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/webchannel-wrapper/rollup.config.js b/packages/webchannel-wrapper/rollup.config.js index e3a45fac8e8..039951f9417 100644 --- a/packages/webchannel-wrapper/rollup.config.js +++ b/packages/webchannel-wrapper/rollup.config.js @@ -25,10 +25,6 @@ import pkg from './package.json'; const closureBlobsDir = '../../node_modules/closure-net/firebase/'; -const deps = [ - ...Object.keys(Object.assign({}, pkg.peerDependencies, pkg.dependencies)) -]; - const es2017BuildPlugins = [ copy({ targets: [ @@ -58,7 +54,6 @@ const esm2017Builds = [ format: 'es', sourcemap: true }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ ...es2017BuildPlugins, emitModulePackageFile() @@ -71,7 +66,6 @@ const esm2017Builds = [ format: 'es', sourcemap: true }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ ...es2017BuildPlugins, emitModulePackageFile() From cdf7d75f5338f730cebd9c0d9986677c583f48f5 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Wed, 24 Apr 2024 15:22:02 -0700 Subject: [PATCH 3/3] formatting --- packages/webchannel-wrapper/empty.js | 17 +++++++++++++++++ packages/webchannel-wrapper/rollup.config.js | 19 ++++++++----------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/packages/webchannel-wrapper/empty.js b/packages/webchannel-wrapper/empty.js index c4f021dd238..0a92763191f 100644 --- a/packages/webchannel-wrapper/empty.js +++ b/packages/webchannel-wrapper/empty.js @@ -1,3 +1,20 @@ +/** + * @license + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /** * This package has no main entry point and only allows imports from its * two subpaths. This file is provided for the top-level package.json diff --git a/packages/webchannel-wrapper/rollup.config.js b/packages/webchannel-wrapper/rollup.config.js index 039951f9417..77c29ecb4ac 100644 --- a/packages/webchannel-wrapper/rollup.config.js +++ b/packages/webchannel-wrapper/rollup.config.js @@ -1,6 +1,6 @@ /** * @license - * Copyright 2019 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,8 +28,11 @@ const closureBlobsDir = '../../node_modules/closure-net/firebase/'; const es2017BuildPlugins = [ copy({ targets: [ - { src: join(closureBlobsDir, 'webchannel_blob_*.*'), dest: 'dist/webchannel-blob'}, - { src: join(closureBlobsDir, 'bloom_blob_*.*'), dest: 'dist/bloom-blob'}, + { + src: join(closureBlobsDir, 'webchannel_blob_*.*'), + dest: 'dist/webchannel-blob' + }, + { src: join(closureBlobsDir, 'bloom_blob_*.*'), dest: 'dist/bloom-blob' } ] }), typescriptPlugin({ @@ -54,10 +57,7 @@ const esm2017Builds = [ format: 'es', sourcemap: true }, - plugins: [ - ...es2017BuildPlugins, - emitModulePackageFile() - ] + plugins: [...es2017BuildPlugins, emitModulePackageFile()] }, { input: join(closureBlobsDir, 'bloom_blob_es2018.js'), @@ -66,10 +66,7 @@ const esm2017Builds = [ format: 'es', sourcemap: true }, - plugins: [ - ...es2017BuildPlugins, - emitModulePackageFile() - ] + plugins: [...es2017BuildPlugins, emitModulePackageFile()] } ];