diff --git a/src/index.ts b/src/index.ts index afd6584..e44802b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -126,20 +126,9 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin { }); if(resolved){ - const moduleId = resolved.id; const moduleExt = extname(resolved.id); const moduleName = specifier.replace(new RegExp(`${moduleExt}\$`),''); // strip extension of the name if any - // const htmlModule : HtmlModule = htmlModules.get(moduleId) ?? { - // id: resolved.id, - // name: moduleName, - // imports: [], - // assetId: null, - // importers: new Set(), - // }; - // htmlModule.importers.add(importer); - // htmlModules.set(htmlModule.id, htmlModule); - // TODO: trigger special handling when imported from a JS file (in which case we want might want to export a module returning the HTML, instead of HTML directly) return { ...resolved, meta: { @@ -158,10 +147,9 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin { } }, load: { - // Something to figure out: its counter intuitive that rollup expects the load-callback to already return JS. It implies we already do transformations and can't really use rollup to further transform any of it. (i.e handlebars > intermediate-html > html would not be possible?) async handler(id: string) { if (virtualSources.has(id)) return virtualSources.get(id); - if (!filter(id)) return; + // if (!filter(id)) return; } }, transform: { @@ -185,9 +173,6 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin { importers: new Set(), } } - // const htmlModule = htmlModules.get(id); - - // const contents = await readFile(id, {encoding: "utf-8"}); const contents = code; const htmlSrc = transform ? await transform(contents, { @@ -284,15 +269,12 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin { const assetId: string = `asset${moduleImports.length}`; moduleImports.push(`import ${assetId} from "${htmlImport.id}";`);// TODO: This is just the easy & safe solution. Would prefer to have recognizable names, and reeuse when something is the exact same resource.. htmlJS = htmlJS.replace(htmlImport.placeholder, `\${${assetId}}`);// TODO: Should we be worried about windows absolute URLs here? - // }else if(htmlImport.type === 'entryChunk' && htmlImport.referenceId){ - // html = html.replace(htmlImport.placeholder, `\${import.meta.ROLLUP_FILE_URL_${htmlImport.referenceId}\}`); }else{ // TODO: this will probably not do for complicated cases ( presumably no other method then emitting the chunk as file, loading its result but excluding it from the output bundle) // html = html.replace(htmlImport.placeholder, htmlImport.loaded?.code||htmlImport.source||''); } } - // TODO when importing html from .js this will not do. ( htmlJS.prepend([ ...moduleImports, `export const html = \`` @@ -338,7 +320,6 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin { } }, resolveFileUrl(options){ - // const htmlModule = htmlModules.get(options.moduleId); const moduleInfo = this.getModuleInfo(options.moduleId); const htmlModule = moduleInfo?.meta?.[pluginName]; if(htmlModule){