Skip to content

Commit

Permalink
Target ES6 for Console Build (#6563)
Browse files Browse the repository at this point in the history
* Target ES6 for Console Build

* Fix format for console
  • Loading branch information
wu-hui committed Aug 29, 2022
1 parent b993aee commit ca1b0c8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/firestore-compat/tools/console.build.js
Expand Up @@ -34,12 +34,17 @@ const EXPORTNAME = '__firestore_exports__';
const OUTPUT_FOLDER = 'dist';
const OUTPUT_FILE = 'standalone.js';

const es5InputOptions = {
const es6InputOptions = {
input: 'src/index.console.ts',
plugins: [
nodeResolve(),
typescriptPlugin({
typescript,
tsconfigOverride: {
compilerOptions: {
target: 'es6'
}
},
transformers: [rollupUtil.removeAssertTransformer]
}),
json({ preferConst: true }),
Expand All @@ -51,7 +56,7 @@ const es5InputOptions = {
]
};

const es5OutputOptions = {
const es6OutputOptions = {
file: `${OUTPUT_FOLDER}/${OUTPUT_FILE}`,
name: EXPORTNAME,
format: 'iife'
Expand All @@ -60,18 +65,18 @@ const es5OutputOptions = {
const POSTFIX = `window['${EXPORTNAME}']=${EXPORTNAME};`;

async function build() {
const es5Bundle = await rollup.rollup(es5InputOptions);
const es6Bundle = await rollup.rollup(es6InputOptions);
const {
output: [{ code }]
} = await es5Bundle.generate(es5OutputOptions);
} = await es6Bundle.generate(es6OutputOptions);

const output = `${String(code)}${POSTFIX}`;

if (!fs.existsSync(OUTPUT_FOLDER)) {
fs.mkdirSync(OUTPUT_FOLDER);
}

await fs_writeFile(es5OutputOptions.file, output, 'utf-8');
await fs_writeFile(es6OutputOptions.file, output, 'utf-8');
}

build();

0 comments on commit ca1b0c8

Please sign in to comment.