| 61 | }; |
| 62 | |
| 63 | const build = async (contents: string) => { |
| 64 | const res = await esbuild.build({ |
| 65 | tsconfigRaw: '{"compilerOptions":{"experimentalDecorators":true}}', |
| 66 | format: 'iife' as 'iife', |
| 67 | bundle: true, |
| 68 | outdir: tmp, |
| 69 | sourcemap: SystemModel.get('ui-default.nosourcemap') ? false : 'external', |
| 70 | splitting: false, |
| 71 | write: false, |
| 72 | target: ['chrome65'], |
| 73 | plugins: [ |
| 74 | ...(global.Hydro.ui.esbuildPlugins || []), |
| 75 | federationPlugin, |
| 76 | ], |
| 77 | minify: !process.env.DEV, |
| 78 | stdin: { |
| 79 | contents, |
| 80 | sourcefile: 'stdin.ts', |
| 81 | resolveDir: tmp, |
| 82 | loader: 'ts', |
| 83 | }, |
| 84 | }); |
| 85 | if (res.errors.length) console.error(res.errors); |
| 86 | if (res.warnings.length) console.warn(res.warnings); |
| 87 | return res; |
| 88 | }; |
| 89 | |
| 90 | const applyCss = (css: string) => ` |
| 91 | const style = document.createElement('style'); |