chore: remove outdated todos and commented code
This commit is contained in:
parent
71a377417d
commit
2adfbee74b
21
src/index.ts
21
src/index.ts
@ -126,20 +126,9 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if(resolved){
|
if(resolved){
|
||||||
const moduleId = resolved.id;
|
|
||||||
const moduleExt = extname(resolved.id);
|
const moduleExt = extname(resolved.id);
|
||||||
const moduleName = specifier.replace(new RegExp(`${moduleExt}\$`),''); // strip extension of the name if any
|
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 {
|
return {
|
||||||
...resolved,
|
...resolved,
|
||||||
meta: {
|
meta: {
|
||||||
@ -158,10 +147,9 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
load: {
|
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) {
|
async handler(id: string) {
|
||||||
if (virtualSources.has(id)) return virtualSources.get(id);
|
if (virtualSources.has(id)) return virtualSources.get(id);
|
||||||
if (!filter(id)) return;
|
// if (!filter(id)) return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transform: {
|
transform: {
|
||||||
@ -185,9 +173,6 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin {
|
|||||||
importers: new Set(),
|
importers: new Set(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// const htmlModule = htmlModules.get(id);
|
|
||||||
|
|
||||||
// const contents = await readFile(id, {encoding: "utf-8"});
|
|
||||||
const contents = code;
|
const contents = code;
|
||||||
|
|
||||||
const htmlSrc = transform ? await transform(contents, {
|
const htmlSrc = transform ? await transform(contents, {
|
||||||
@ -284,15 +269,12 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin {
|
|||||||
const assetId: string = `asset${moduleImports.length}`;
|
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..
|
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?
|
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{
|
}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)
|
// 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||'');
|
// html = html.replace(htmlImport.placeholder, htmlImport.loaded?.code||htmlImport.source||'');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO when importing html from .js this will not do. (
|
|
||||||
htmlJS.prepend([
|
htmlJS.prepend([
|
||||||
...moduleImports,
|
...moduleImports,
|
||||||
`export const html = \``
|
`export const html = \``
|
||||||
@ -338,7 +320,6 @@ export default function html(opts: RollupHtmlOptions = {}): Plugin {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
resolveFileUrl(options){
|
resolveFileUrl(options){
|
||||||
// const htmlModule = htmlModules.get(options.moduleId);
|
|
||||||
const moduleInfo = this.getModuleInfo(options.moduleId);
|
const moduleInfo = this.getModuleInfo(options.moduleId);
|
||||||
const htmlModule = moduleInfo?.meta?.[pluginName];
|
const htmlModule = moduleInfo?.meta?.[pluginName];
|
||||||
if(htmlModule){
|
if(htmlModule){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user