mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-11 16:26:20 +00:00
Add an error for unsupported usage of new URL
This commit is contained in:
committed by
Ingvar Stepanyan
parent
d07c57ecaa
commit
2037fe8964
@@ -33,11 +33,23 @@ import initialCssPlugin from './lib/initial-css-plugin';
|
||||
import serviceWorkerPlugin from './lib/sw-plugin';
|
||||
import dataURLPlugin from './lib/data-url-plugin';
|
||||
import entryDataPlugin, { fileNameToURL } from './lib/entry-data-plugin';
|
||||
import dedent from 'dedent';
|
||||
|
||||
function resolveFileUrl({ fileName }) {
|
||||
return JSON.stringify(fileNameToURL(fileName));
|
||||
}
|
||||
|
||||
function resolveImportMetaUrlInStaticBuild(property, { moduleId }) {
|
||||
if (property !== 'url') return;
|
||||
throw new Error(dedent`
|
||||
Attempted to use a \`new URL(..., import.meta.url)\` pattern in ${path.relative(
|
||||
process.cwd(),
|
||||
moduleId,
|
||||
)} for URL that needs to end up in static HTML.
|
||||
This is currently unsupported.
|
||||
`);
|
||||
}
|
||||
|
||||
const dir = '.tmp/build';
|
||||
const staticPath = 'static/c/[name]-[hash][extname]';
|
||||
const jsPath = staticPath.replace('[extname]', '.js');
|
||||
@@ -100,7 +112,7 @@ export default async function ({ watch }) {
|
||||
},
|
||||
preserveModules: true,
|
||||
plugins: [
|
||||
{ resolveFileUrl },
|
||||
{ resolveFileUrl, resolveImportMeta: resolveImportMetaUrlInStaticBuild },
|
||||
clientBundlePlugin(
|
||||
{
|
||||
external: ['worker_threads'],
|
||||
|
||||
Reference in New Issue
Block a user