Skip to content

use esm2017 builds by default #5539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/heavy-books-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@firebase/logger": minor
"@firebase/util": minor
"@firebase/webchannel-wrapper": minor
---

Use esm2017 builds by default
5 changes: 5 additions & 0 deletions .changeset/wet-queens-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/firestore": patch
---

use `constructor.name` for Object type
2 changes: 1 addition & 1 deletion config/webpack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module.exports = {
options: {
compilerOptions: {
module: 'commonjs',
target: 'es5',
target: 'es2017',
downlevelIteration: true,
resolveJsonModule: true
}
Expand Down
8 changes: 2 additions & 6 deletions packages/firestore/src/util/input_validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,10 @@ export function valueDescription(input: unknown): string {
}
}

/** Hacky method to try to get the constructor name for an object. */
/** try to get the constructor name for an object. */
export function tryGetCustomObjectType(input: object): string | null {
if (input.constructor) {
const funcNameRegex = /function\s+([^\s(]+)\s*\(/;
const results = funcNameRegex.exec(input.constructor.toString());
if (results && results.length > 1) {
return results[1];
}
return input.constructor.name;
Copy link
Member Author

@Feiyang1 Feiyang1 Sep 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@schmidt-sebastian I changed the compilation target to es2017 for testing, which preserves class definitions and revealed that this function doesn't work with classes. Changed to use constructor.name which is available everywhere except IE, which we don't need to worry about anymore. - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#browser_compatibility

}
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "A logger package for use in the Firebase JS SDK",
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"esm2017": "dist/index.esm2017.js",
"module": "dist/index.esm2017.js",
"esm5": "dist/index.esm5.js",
"files": ["dist"],
"scripts": {
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
Expand Down
4 changes: 2 additions & 2 deletions packages/logger/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const es5Builds = [
input: 'index.ts',
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true }
{ file: pkg.esm5, format: 'es', sourcemap: true }
],
plugins: es5BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
Expand All @@ -62,7 +62,7 @@ const es2017Builds = [
{
input: 'index.ts',
output: {
file: pkg.esm2017,
file: pkg.module,
format: 'es',
sourcemap: true
},
Expand Down
6 changes: 3 additions & 3 deletions packages/util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"description": "",
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"main": "dist/index.node.cjs.js",
"browser": "dist/index.esm.js",
"module": "dist/index.esm.js",
"esm2017": "dist/index.esm2017.js",
"browser": "dist/index.esm2017.js",
"module": "dist/index.esm2017.js",
"esm5": "dist/index.esm5.js",
"files": [
"dist"
],
Expand Down
4 changes: 2 additions & 2 deletions packages/util/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const es5Builds = [
*/
{
input: 'index.ts',
output: [{ file: pkg.module, format: 'es', sourcemap: true }],
output: [{ file: pkg.esm5, format: 'es', sourcemap: true }],
plugins: es5BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
},
Expand Down Expand Up @@ -72,7 +72,7 @@ const es2017Builds = [
{
input: 'index.ts',
output: {
file: pkg.esm2017,
file: pkg.module,
format: 'es',
sourcemap: true
},
Expand Down
4 changes: 2 additions & 2 deletions packages/webchannel-wrapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "A wrapper of the webchannel packages from closure-library for use outside of a closure compiled application",
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"main": "dist/index.js",
"module": "dist/index.esm.js",
"esm2017": "dist/index.esm2017.js",
"module": "dist/index.esm2017.js",
"esm5": "dist/index.esm.js",
"files": [
"dist"
],
Expand Down