Skip to content

Commit

Permalink
fix(bundle-source): Revert breaking export types change
Browse files Browse the repository at this point in the history
This reverts commit 50518da.
  • Loading branch information
kriskowal committed Mar 19, 2024
1 parent 4222776 commit 58e82f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
11 changes: 5 additions & 6 deletions packages/bundle-source/src/bundle-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
const DEFAULT_MODULE_FORMAT = 'endoZipBase64';
const SUPPORTED_FORMATS = ['getExport', 'nestedEvaluate', 'endoZipBase64'];

/**
* @type {import('./types').BundleSourceGeneral}
*/
/** @type {import('./types').BundleSource} */
// @ts-ignore cast
const bundleSource = async (
startFilename,
options = {},
Expand All @@ -14,6 +13,8 @@ const bundleSource = async (
if (typeof options === 'string') {
options = { format: options };
}
/** @type {{ format: import('./types').ModuleFormat }} */
// @ts-expect-error cast (xxx params)
const { format: moduleFormat = DEFAULT_MODULE_FORMAT } = options;

switch (moduleFormat) {
Expand Down Expand Up @@ -51,6 +52,4 @@ const bundleSource = async (
}
};

export default /** @satisfies {import('./types').BundleSource} */ (
bundleSource
);
export default bundleSource;
9 changes: 5 additions & 4 deletions packages/bundle-source/src/nested-evaluate-and-get-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ function longestCommonPrefix(strings) {
}

/**
* @type {import('./types').BundleSourceWithFormat}
* @template {'nestedEvaluate' | 'getExport'} T
* @param {string} startFilename
* @param {T} moduleFormat
* @param {any} powers
*/
export async function bundleNestedEvaluateAndGetExports(
startFilename,
Expand All @@ -44,7 +47,7 @@ export async function bundleNestedEvaluateAndGetExports(
pathResolve = path.resolve,
pathToFileURL = url.pathToFileURL,
externals = [],
} = /** @type {any} */ (powers || {});
} = powers || {};
const resolvedPath = pathResolve(startFilename);
const bundle = await rollup({
input: resolvedPath,
Expand Down Expand Up @@ -157,7 +160,6 @@ ${sourceBundle[entrypoint]}
return module.exports;
}
${sourceMap}`;
// @ts-expect-error generic T not assignable to moduleFormat
return harden({ moduleFormat, source, sourceMap });
} else if (moduleFormat === 'nestedEvaluate') {
sourceMap = `//# sourceURL=${DEFAULT_FILE_PREFIX}-preamble.js\n`;
Expand Down Expand Up @@ -282,7 +284,6 @@ function getExportWithNestedEvaluate(filePrefix) {
return computeExports(entrypoint, { require: systemRequire, systemEval }, {});
}
${sourceMap}`;
// @ts-expect-error generic T not assignable to moduleFormat
return harden({ moduleFormat, source, sourceMap });
}

Expand Down
5 changes: 1 addition & 4 deletions packages/bundle-source/src/zip-base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ const textEncoder = new TextEncoder();
const textDecoder = new TextDecoder();
const readPowers = makeReadPowers({ fs, url, crypto });

/**
* @type {import('./types').BundleSourceWithOptions}
*/
export async function bundleZipBase64(
startFilename,
options,
options = {},
grantedPowers = {},
) {
const { dev = false, cacheSourceMaps = false, commonDependencies } = options;
Expand Down

0 comments on commit 58e82f0

Please sign in to comment.