(options)
| 157 | * @returns {Promise<CesiumBundles>} |
| 158 | */ |
| 159 | export async function bundleCesiumJs(options) { |
| 160 | const buildConfig = defaultESBuildOptions(); |
| 161 | buildConfig.entryPoints = ["Source/Cesium.js"]; |
| 162 | buildConfig.minify = options.minify; |
| 163 | buildConfig.sourcemap = options.sourcemap; |
| 164 | buildConfig.plugins = options.removePragmas ? [stripPragmaPlugin] : undefined; |
| 165 | buildConfig.write = options.write; |
| 166 | buildConfig.banner = { |
| 167 | js: await getCopyrightHeader(), |
| 168 | }; |
| 169 | // print errors immediately, and collect warnings so we can filter out known ones |
| 170 | buildConfig.logLevel = "info"; |
| 171 | |
| 172 | /** @type {CesiumBundles} */ |
| 173 | const contexts = {}; |
| 174 | const incremental = options.incremental; |
| 175 | const build = incremental ? esbuild.context : esbuild.build; |
| 176 | |
| 177 | // Build ESM |
| 178 | const esm = await build({ |
| 179 | ...buildConfig, |
| 180 | format: "esm", |
| 181 | outfile: path.join(options.path, "index.js"), |
| 182 | }); |
| 183 | |
| 184 | if (incremental) { |
| 185 | contexts.esm = esm; |
| 186 | } else { |
| 187 | handleBuildWarnings(/** @type {esbuild.BuildResult} */ (esm)); |
| 188 | } |
| 189 | |
| 190 | // Build IIFE |
| 191 | if (options.iife) { |
| 192 | const iifeWorkers = await bundleWorkers({ |
| 193 | iife: true, |
| 194 | minify: options.minify, |
| 195 | sourcemap: false, |
| 196 | path: options.path, |
| 197 | removePragmas: options.removePragmas, |
| 198 | incremental: incremental, |
| 199 | write: options.write, |
| 200 | }); |
| 201 | |
| 202 | const iife = await build({ |
| 203 | ...buildConfig, |
| 204 | format: "iife", |
| 205 | inject: [inlineWorkerPath], |
| 206 | globalName: "Cesium", |
| 207 | outfile: path.join(options.path, "Cesium.js"), |
| 208 | logOverride: { |
| 209 | "empty-import-meta": "silent", |
| 210 | }, |
| 211 | }); |
| 212 | |
| 213 | if (incremental) { |
| 214 | contexts.iife = iife; |
| 215 | contexts.iifeWorkers = /** @type {esbuild.BuildContext} */ (iifeWorkers); |
| 216 | } else { |
no test coverage detected
searching dependent graphs…