Skip to content

Commit

Permalink
Emit a module package file for functions ESM builds (#8517)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlarocque committed Sep 26, 2024
1 parent 36cb017 commit 6b035b7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
10 changes: 5 additions & 5 deletions packages/functions-compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
"description": "",
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm2017.js",
"module": "dist/index.esm2017.js",
"browser": "dist/esm/index.esm2017.js",
"module": "dist/esm/index.esm2017.js",
"exports": {
".": {
"types": "./dist/src/index.d.ts",
"node": {
"require": "./dist/index.cjs.js",
"import": "./dist/index.esm2017.js"
"import": "./dist/esm/index.esm2017.js"
},
"browser": {
"require": "./dist/index.cjs.js",
"import": "./dist/index.esm2017.js"
"import": "./dist/esm/index.esm2017.js"
},
"default": "./dist/index.esm2017.js"
"default": "./dist/esm/index.esm2017.js"
},
"./package.json": "./package.json"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/functions-compat/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ const buildPlugins = [
json({ preferConst: true })
];

const browserBuilds = [
const builds = [
{
input: 'src/index.ts',
output: {
file: pkg.browser,
format: 'es',
sourcemap: true
},
plugins: buildPlugins,
plugins: [...buildPlugins, emitModulePackageFile()],
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
},
{
input: 'src/index.ts',
output: {
file: './dist/index.cjs.js',
file: pkg.main,
format: 'cjs',
sourcemap: true
},
Expand All @@ -55,4 +55,4 @@ const browserBuilds = [
}
];

export default [...browserBuilds];
export default builds;
10 changes: 5 additions & 5 deletions packages/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
"description": "",
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
"main": "dist/index.cjs.js",
"browser": "dist/index.esm2017.js",
"module": "dist/index.esm2017.js",
"browser": "dist/esm/index.esm2017.js",
"module": "dist/esm/index.esm2017.js",
"exports": {
".": {
"types": "./dist/functions-public.d.ts",
"node": {
"import": "./dist/index.esm2017.js",
"import": "./dist/esm/index.esm2017.js",
"require": "./dist/index.cjs.js"
},
"browser": {
"require": "./dist/index.cjs.js",
"import": "./dist/index.esm2017.js"
"import": "./dist/esm/index.esm2017.js"
},
"default": "./dist/index.esm2017.js"
"default": "./dist/esm/index.esm2017.js"
},
"./package.json": "./package.json"
},
Expand Down
9 changes: 5 additions & 4 deletions packages/functions/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const buildPlugins = [
json({ preferConst: true })
];

const browserBuilds = [
const builds = [
{
input: 'src/index.ts',
output: {
Expand All @@ -45,13 +45,14 @@ const browserBuilds = [
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)),
plugins: [
...buildPlugins,
replace(generateBuildTargetReplaceConfig('esm', 2017))
replace(generateBuildTargetReplaceConfig('esm', 2017)),
emitModulePackageFile()
]
},
{
input: 'src/index.ts',
output: {
file: './dist/index.cjs.js',
file: pkg.main,
format: 'cjs',
sourcemap: true
},
Expand All @@ -63,4 +64,4 @@ const browserBuilds = [
}
];

export default [...browserBuilds];
export default builds;

0 comments on commit 6b035b7

Please sign in to comment.