(config: BuildConfig)
| 17 | |
| 18 | /** Builds @builder.io/optimizer */ |
| 19 | export async function submoduleOptimizer(config: BuildConfig) { |
| 20 | const submodule = 'optimizer'; |
| 21 | |
| 22 | // Uncomment this to regenerate the platform binding map for the optimizer. This is only necessary when adding new platform bindings to qwik, and should be committed to source control. |
| 23 | // await generatePlatformBindingsData(config); |
| 24 | |
| 25 | async function buildOptimizer() { |
| 26 | const opts: BuildOptions = { |
| 27 | entryPoints: [join(config.srcQwikDir, submodule, 'src', 'index.ts')], |
| 28 | entryNames: 'optimizer', |
| 29 | outdir: config.distQwikPkgDir, |
| 30 | bundle: true, |
| 31 | sourcemap: false, |
| 32 | platform: 'node', |
| 33 | target, |
| 34 | external: [ |
| 35 | /* no Node.js built-in externals allowed! */ |
| 36 | 'espree', |
| 37 | 'launch-editor', |
| 38 | ], |
| 39 | }; |
| 40 | |
| 41 | const qwikloaderScripts = await inlineQwikScriptsEsBuild(config); |
| 42 | |
| 43 | const esmBuild = build({ |
| 44 | ...opts, |
| 45 | format: 'esm', |
| 46 | banner: { js: getBanner('@builder.io/qwik/optimizer', config.distVersion) }, |
| 47 | outExtension: { '.js': '.mjs' }, |
| 48 | define: { |
| 49 | 'globalThis.IS_CJS': 'false', |
| 50 | 'globalThis.IS_ESM': 'true', |
| 51 | 'globalThis.QWIK_VERSION': JSON.stringify(config.distVersion), |
| 52 | ...qwikloaderScripts, |
| 53 | }, |
| 54 | plugins: [RawPlugin()], |
| 55 | }); |
| 56 | |
| 57 | const cjsBanner = [`globalThis.qwikOptimizer = (function (module) {`].join('\n'); |
| 58 | |
| 59 | const cjsBuild = build({ |
| 60 | ...opts, |
| 61 | format: 'cjs', |
| 62 | banner: { js: cjsBanner }, |
| 63 | footer: { |
| 64 | js: `return module.exports; })(typeof module === 'object' && module.exports ? module : { exports: {} });`, |
| 65 | }, |
| 66 | outExtension: { '.js': '.cjs' }, |
| 67 | define: { |
| 68 | 'globalThis.IS_CJS': 'true', |
| 69 | 'globalThis.IS_ESM': 'false', |
| 70 | 'globalThis.QWIK_VERSION': JSON.stringify(config.distVersion), |
| 71 | ...qwikloaderScripts, |
| 72 | }, |
| 73 | target: nodeTarget, |
| 74 | plugins: [RawPlugin()], |
| 75 | }); |
| 76 |
no test coverage detected
searching dependent graphs…