-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: upgrade esbuild + add logging to JS api
- Loading branch information
Showing
17 changed files
with
186 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,70 @@ | ||
#!/usr/bin/env node | ||
import { build } from 'esbuild'; | ||
import esbuild from 'esbuild'; | ||
|
||
const themes = ['classic', 'microvideo', 'minimal', 'gerwig']; | ||
const devMode = process.argv.includes('--dev'); | ||
|
||
const shared = { | ||
bundle: true, | ||
target: 'es2019', | ||
logLevel: 'info', | ||
loader: { | ||
'.html': 'text', | ||
'.css': 'text', | ||
'.svg': 'text', | ||
}, | ||
watch: devMode, | ||
}; | ||
|
||
// entryPoints doesn't support glob patterns so we iterate over known themes | ||
themes.forEach((theme) => { | ||
for (const theme of themes) { | ||
//@ts-ignore | ||
build({ | ||
const esm = { | ||
...shared, | ||
entryPoints: [`./src/themes/${theme}/index.ts`], | ||
format: 'esm', | ||
outExtension: { '.js': '.mjs' }, | ||
outdir: `./dist/themes/${theme}`, | ||
}); | ||
}; | ||
|
||
if (devMode) { | ||
const context = await esbuild.context(esm); | ||
await context.rebuild(); | ||
await context.watch(); | ||
} else { | ||
await esbuild.build(esm); | ||
} | ||
|
||
//@ts-ignore | ||
build({ | ||
const cjs = { | ||
...shared, | ||
entryPoints: [`./src/themes/${theme}/index.ts`], | ||
format: 'cjs', | ||
outExtension: { '.js': '.cjs.js' }, | ||
outdir: `./dist/themes/${theme}`, | ||
}); | ||
}; | ||
|
||
if (devMode) { | ||
const context = await esbuild.context(cjs); | ||
await context.rebuild(); | ||
await context.watch(); | ||
} else { | ||
await esbuild.build(cjs); | ||
} | ||
|
||
//@ts-ignore | ||
build({ | ||
const iife = { | ||
...shared, | ||
entryPoints: [`./src/themes/${theme}/index.ts`], | ||
format: 'iife', | ||
globalName: `mediaTheme${theme[0].toUpperCase() + theme.slice(1)}`, | ||
outdir: `./dist/themes/${theme}`, | ||
}); | ||
}); | ||
}; | ||
|
||
if (devMode) { | ||
const context = await esbuild.context(iife); | ||
await context.rebuild(); | ||
await context.watch(); | ||
} else { | ||
await esbuild.build(iife); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,6 @@ | |
"esbuilder": "./esbuilder.js" | ||
}, | ||
"dependencies": { | ||
"esbuild": "^0.15.7" | ||
"esbuild": "^0.19.8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.