(module, dir = DIST_DIR, min = false)
| 526 | }; |
| 527 | |
| 528 | const compileModule = async (module, dir = DIST_DIR, min = false) => { |
| 529 | const {default: esbuild} = await import('rollup-plugin-esbuild'); |
| 530 | const {rollup} = await import('rollup'); |
| 531 | const {babel} = await import('@rollup/plugin-babel'); |
| 532 | const {default: replace} = await import('@rollup/plugin-replace'); |
| 533 | const {default: prettierPlugin} = await import('rollup-plugin-prettier'); |
| 534 | const {default: shebang} = await import('rollup-plugin-preserve-shebang'); |
| 535 | const {default: image} = await import('@rollup/plugin-image'); |
| 536 | const {default: terser} = await import('@rollup/plugin-terser'); |
| 537 | const sveltePlugin = moduleIsSvelte(module) |
| 538 | ? (await import('rollup-plugin-svelte')).default |
| 539 | : null; |
| 540 | const uiModule = getUiModule(module); |
| 541 | |
| 542 | let inputFile = `src/${module}/index.ts`; |
| 543 | if (!existsSync(inputFile)) { |
| 544 | inputFile += 'x'; |
| 545 | } |
| 546 | |
| 547 | const inputConfig = { |
| 548 | external: [ |
| 549 | 'cloudflare:workers', |
| 550 | 'expo-sqlite', |
| 551 | 'fs', |
| 552 | 'fs/promises', |
| 553 | 'path', |
| 554 | 'prettier/standalone', |
| 555 | 'prettier/plugins/estree', |
| 556 | 'prettier/plugins/typescript', |
| 557 | 'react', |
| 558 | 'react-dom', |
| 559 | 'react/jsx-runtime', |
| 560 | 'solid-js', |
| 561 | 'solid-js/web', |
| 562 | 'solid-js/jsx-runtime', |
| 563 | 'url', |
| 564 | 'yjs', |
| 565 | ...(module == 'omni' |
| 566 | ? [] |
| 567 | : ['tinybase/store', '../ui-react', '../ui-solid', '../' + uiModule]), |
| 568 | ...(moduleIsSvelte(module) ? [/^svelte/] : []), |
| 569 | ], |
| 570 | input: inputFile, |
| 571 | plugins: [ |
| 572 | esbuild({ |
| 573 | target: 'esnext', |
| 574 | legalComments: 'inline', |
| 575 | logOverride: {'unsupported-jsx-comment': 'silent'}, |
| 576 | tsconfig: moduleIsSolid(module) ? false : undefined, |
| 577 | jsx: moduleIsSolid(module) ? 'preserve' : 'automatic', |
| 578 | }), |
| 579 | moduleIsSolid(module) |
| 580 | ? babel({ |
| 581 | babelHelpers: 'bundled', |
| 582 | extensions: ['.tsx'], |
| 583 | include: 'src/**/*.tsx', |
| 584 | presets: [['solid', {delegateEvents: false}]], |
| 585 | }) |
searching dependent graphs…