mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-12 16:57:26 +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 serviceWorkerPlugin from './lib/sw-plugin';
|
||||||
import dataURLPlugin from './lib/data-url-plugin';
|
import dataURLPlugin from './lib/data-url-plugin';
|
||||||
import entryDataPlugin, { fileNameToURL } from './lib/entry-data-plugin';
|
import entryDataPlugin, { fileNameToURL } from './lib/entry-data-plugin';
|
||||||
|
import dedent from 'dedent';
|
||||||
|
|
||||||
function resolveFileUrl({ fileName }) {
|
function resolveFileUrl({ fileName }) {
|
||||||
return JSON.stringify(fileNameToURL(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 dir = '.tmp/build';
|
||||||
const staticPath = 'static/c/[name]-[hash][extname]';
|
const staticPath = 'static/c/[name]-[hash][extname]';
|
||||||
const jsPath = staticPath.replace('[extname]', '.js');
|
const jsPath = staticPath.replace('[extname]', '.js');
|
||||||
@@ -100,7 +112,7 @@ export default async function ({ watch }) {
|
|||||||
},
|
},
|
||||||
preserveModules: true,
|
preserveModules: true,
|
||||||
plugins: [
|
plugins: [
|
||||||
{ resolveFileUrl },
|
{ resolveFileUrl, resolveImportMeta: resolveImportMetaUrlInStaticBuild },
|
||||||
clientBundlePlugin(
|
clientBundlePlugin(
|
||||||
{
|
{
|
||||||
external: ['worker_threads'],
|
external: ['worker_threads'],
|
||||||
|
|||||||
Reference in New Issue
Block a user