forked from QwikDev/qwik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmodule-jsx-runtime.ts
47 lines (41 loc) · 1.34 KB
/
submodule-jsx-runtime.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { build, BuildOptions } from 'esbuild';
import { join } from 'node:path';
import { BuildConfig, importPath, target, watcher } from './util';
/**
* Builds @builder.io/qwik/jsx-runtime
*
* This build mainly is re-exports the jsx runtime functions
* provided by the core. Internally, the core's JSX renderer
* is using the latest jsx transform, but Qwik provides both
* the legacy `h()` jsx factory, and the `jsx()` runtime.
*
* - https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
* - https://www.typescriptlang.org/tsconfig#jsxImportSource
*/
export async function submoduleJsxRuntime(config: BuildConfig) {
const submodule = 'jsx-runtime';
const opts: BuildOptions = {
entryPoints: [join(config.srcDir, 'jsx-runtime', 'index.ts')],
entryNames: 'jsx-runtime',
outdir: config.distPkgDir,
bundle: true,
sourcemap: true,
target,
};
const esm = build({
...opts,
format: 'esm',
outExtension: { '.js': '.mjs' },
plugins: [importPath(/^@builder\.io\/qwik$/, '@builder.io/qwik')],
watch: watcher(config, submodule),
});
const cjs = build({
...opts,
format: 'cjs',
outExtension: { '.js': '.cjs' },
plugins: [importPath(/^@builder\.io\/qwik$/, '@builder.io/qwik')],
watch: watcher(config),
});
await Promise.all([esm, cjs]);
console.log('🐮', submodule);
}