mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-13 17:27:09 +00:00
Inline initial script
This commit is contained in:
@@ -15,6 +15,7 @@ import rollup from 'rollup';
|
||||
const prefix = 'client-bundle:';
|
||||
const entryPathPlaceholder = 'CLIENT_BUNDLE_PLUGIN_ENTRY_PATH';
|
||||
const importsPlaceholder = 'CLIENT_BUNDLE_PLUGIN_IMPORTS';
|
||||
const allSrcPlaceholder = 'CLIENT_BUNDLE_PLUGIN_ALL_SRC';
|
||||
|
||||
export function getDependencies(clientOutput, item) {
|
||||
const crawlDependencies = new Set([item.fileName]);
|
||||
@@ -70,6 +71,9 @@ export default function (inputOptions, outputOptions, resolveFileUrl) {
|
||||
`export const imports = import.meta.${
|
||||
importsPlaceholder + exportCounter
|
||||
};`,
|
||||
`export const allSrc = import.meta.${
|
||||
allSrcPlaceholder + exportCounter
|
||||
};`,
|
||||
].join('\n');
|
||||
},
|
||||
async buildEnd(error) {
|
||||
@@ -108,6 +112,8 @@ export default function (inputOptions, outputOptions, resolveFileUrl) {
|
||||
num = Number(property.slice(entryPathPlaceholder.length));
|
||||
} else if (property.startsWith(importsPlaceholder)) {
|
||||
num = Number(property.slice(importsPlaceholder.length));
|
||||
} else if (property.startsWith(allSrcPlaceholder)) {
|
||||
num = Number(property.slice(allSrcPlaceholder.length));
|
||||
} else {
|
||||
// This isn't one of our placeholders.
|
||||
return;
|
||||
@@ -128,6 +134,12 @@ export default function (inputOptions, outputOptions, resolveFileUrl) {
|
||||
|
||||
const dependencies = getDependencies(clientOutput, clientEntry);
|
||||
|
||||
if (property.startsWith(allSrcPlaceholder)) {
|
||||
return JSON.stringify(
|
||||
[clientEntry.code, ...dependencies.map((d) => d.code)].join(';'),
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
'[' +
|
||||
dependencies
|
||||
|
||||
Reference in New Issue
Block a user