| 641 | loadShim(/stringHasher.js/, "string-hasher.js"), |
| 642 | loadShim(/@smithy\/util-base64/, "@smithy/util-base64.js"), |
| 643 | loadShim(/mnemonist\/lru-cache\.js/, "mnemonist/lru-cache.js"), |
| 644 | ]); |
| 645 | } |
| 646 | |
| 647 | async function buildLibrary() { |
| 648 | const defaultLibEsBuildOption = { |
| 649 | chunkNames: "llrt-[name]-runtime-[hash]", |
| 650 | ...ES_BUILD_OPTIONS, |
| 651 | splitting: false, |
| 652 | keepNames: true, |
| 653 | nodePaths: ["."], |
| 654 | }; |
| 655 | |
| 656 | // Build lib |
| 657 | const entryPoints = {}; |
| 658 | ENTRYPOINTS.forEach((entry) => { |
| 659 | entryPoints[entry] = path.join(SRC_DIR, entry); |
| 660 | }); |
| 661 | await esbuild.build({ |
| 662 | ...defaultLibEsBuildOption, |
| 663 | entryPoints, |
| 664 | plugins: [requireProcessPlugin], |
| 665 | sourcemap: false, |
| 666 | }); |
| 667 | |
| 668 | // Build tests |
| 669 | const testEntryPoints = TEST_FILES.reduce((acc, entry) => { |
| 670 | const { name, dir } = path.parse(entry); |
| 671 | const relativeDir = path.relative(path.join(TESTS_DIR, TESTS_SUB_DIR), dir); |
| 672 | const outDir = relativeDir |
| 673 | ? path.join("__tests__", TESTS_SUB_DIR, relativeDir) |
| 674 | : path.join("__tests__", TESTS_SUB_DIR); |
| 675 | acc[path.join(outDir, name)] = entry; |
| 676 | return acc; |
| 677 | }, {}); |
| 678 | |
| 679 | await esbuild.build({ |
| 680 | ...defaultLibEsBuildOption, |
| 681 | entryPoints: testEntryPoints, |