1 | import { pathnameToOperatingSystemPath } from "@jsenv/operating-system-path"
|
2 | import { createLogger } from "@jsenv/logger"
|
3 | import { createJsenvRollupPlugin } from "./jsenv-rollup-plugin.js"
|
4 | import { generateBundleUsingRollup } from "./generate-bundle-using-rollup.js"
|
5 | import { formatToRollupFormat } from "./format-to-rollup-format.js"
|
6 |
|
7 | export const bundleWithoutBalancing = async ({
|
8 | cancellationToken,
|
9 | projectPathname,
|
10 | bundleIntoRelativePath,
|
11 | cache,
|
12 | cacheRelativePath,
|
13 | importDefaultExtension,
|
14 | importMapRelativePath,
|
15 | importMapForBundle,
|
16 | importAbstractMap,
|
17 | importFallbackMap,
|
18 | nativeModulePredicate,
|
19 | entryPointMap,
|
20 | babelPluginMap,
|
21 | convertMap,
|
22 | minify,
|
23 | logLevel,
|
24 | format,
|
25 | formatOutputOptions,
|
26 | writeOnFileSystem,
|
27 | }) => {
|
28 | const logger = createLogger({ logLevel })
|
29 |
|
30 | const dir = pathnameToOperatingSystemPath(`${projectPathname}${bundleIntoRelativePath}`)
|
31 |
|
32 | const { jsenvRollupPlugin, getArrayOfAbstractHref } = await createJsenvRollupPlugin({
|
33 | cancellationToken,
|
34 | projectPathname,
|
35 | bundleIntoRelativePath,
|
36 | cache,
|
37 | cacheRelativePath,
|
38 | entryPointMap,
|
39 | importDefaultExtension,
|
40 | importMapRelativePath,
|
41 | importMapForBundle,
|
42 | importAbstractMap,
|
43 | importFallbackMap,
|
44 | babelPluginMap,
|
45 | convertMap,
|
46 | featureNameArray: Object.keys(babelPluginMap),
|
47 | minify,
|
48 | format,
|
49 | logger,
|
50 | })
|
51 |
|
52 | logger.trace(`
|
53 | bundle entry points without balancing.
|
54 | format: ${format}
|
55 | entry point names: ${Object.keys(entryPointMap)}
|
56 | dir: ${dir}
|
57 | minify: ${minify}
|
58 | `)
|
59 |
|
60 | const rollupBundle = await generateBundleUsingRollup({
|
61 | cancellationToken,
|
62 | writeOnFileSystem,
|
63 | rollupParseOptions: {
|
64 | input: entryPointMap,
|
65 | plugins: [jsenvRollupPlugin],
|
66 | external: (id) => nativeModulePredicate(id),
|
67 | },
|
68 | rollupGenerateOptions: {
|
69 |
|
70 | dir,
|
71 |
|
72 | format: formatToRollupFormat(format),
|
73 |
|
74 |
|
75 | sourcemap: true,
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | sourcemapExcludeSources: false,
|
81 | ...formatOutputOptions,
|
82 | },
|
83 | })
|
84 |
|
85 | return { rollupBundle, arrayOfAbstractHref: getArrayOfAbstractHref() }
|
86 | }
|