diff --git a/packages/cli/src/config/rollup.config.js b/packages/cli/src/config/rollup.config.js index 649aeb5ac..6c9213740 100644 --- a/packages/cli/src/config/rollup.config.js +++ b/packages/cli/src/config/rollup.config.js @@ -132,6 +132,7 @@ function greenwoodSyncPageResourceBundlesPlugin(compilation) { // TODO could we use this instead? // https://github.com/rollup/rollup/blob/v2.79.1/docs/05-plugin-development.md#resolveimportmeta +// https://github.com/ProjectEvergreen/greenwood/issues/1087 function greenwoodPatchSsrPagesEntryPointRuntimeImport() { return { name: 'greenwood-patch-ssr-pages-entry-point-runtime-import', @@ -217,7 +218,7 @@ const getRollupConfigForApis = async (compilation) => { .map(api => normalizePathnameForWindows(new URL(`.${api.path}`, userWorkspace))); // TODO should routes and APIs have chunks? - // https://github.com/ProjectEvergreen/greenwood/issues/1008 + // https://github.com/ProjectEvergreen/greenwood/issues/1118 return [{ input, output: { @@ -238,7 +239,7 @@ const getRollupConfigForSsr = async (compilation, input) => { const { outputDir } = compilation.context; // TODO should routes and APIs have chunks? - // https://github.com/ProjectEvergreen/greenwood/issues/1008 + // https://github.com/ProjectEvergreen/greenwood/issues/1118 return [{ input, output: { @@ -250,6 +251,7 @@ const getRollupConfigForSsr = async (compilation, input) => { greenwoodJsonLoader(), // TODO let this through for lit to enable nodeResolve({ preferBuiltins: true }) // https://github.com/lit/lit/issues/449 + // https://github.com/ProjectEvergreen/greenwood/issues/1118 nodeResolve({ preferBuiltins: true }), @@ -267,6 +269,7 @@ const getRollupConfigForSsr = async (compilation, input) => { // Error: the string "Circular dependency: ../../../../../node_modules/@lit-labs/ssr/lib/render-lit-html.js -> // ../../../../../node_modules/@lit-labs/ssr/lib/lit-element-renderer.js -> ../../../../../node_modules/@lit-labs/ssr/lib/render-lit-html.js\n" was thrown, throw an Error :) // https://github.com/lit/lit/issues/449 + // https://github.com/ProjectEvergreen/greenwood/issues/1118 break; default: // otherwise, log all warnings from rollup diff --git a/packages/cli/src/lib/execute-route-module.js b/packages/cli/src/lib/execute-route-module.js index b1c1c63e2..5b36631fe 100644 --- a/packages/cli/src/lib/execute-route-module.js +++ b/packages/cli/src/lib/execute-route-module.js @@ -1,8 +1,5 @@ import { renderToString, renderFromHTML } from 'wc-compiler'; -// TODO simplify this API signature (lot of things could be combined) -// - route, label and id could just be the current page -// - scripts is already part of the compilation async function executeRouteModule({ moduleUrl, compilation, page = {}, prerender = false, htmlContents = null, scripts = [] }) { const data = { template: null, diff --git a/packages/cli/src/lifecycles/bundle.js b/packages/cli/src/lifecycles/bundle.js index f9d1ad65b..775e5249a 100644 --- a/packages/cli/src/lifecycles/bundle.js +++ b/packages/cli/src/lifecycles/bundle.js @@ -197,26 +197,16 @@ async function bundleSsrPages(compilation) { const entryFileUrl = new URL(`./_${filename}`, scratchDir); const moduleUrl = new URL(`./${filename}`, pagesDir); // TODO getTemplate has to be static (for now?) - // const { getTemplate = null } = await import(new URL(`./${filename}`, pagesDir)); + // https://github.com/ProjectEvergreen/greenwood/issues/955 const data = await executeRouteModule({ moduleUrl, compilation, page, prerender: false, htmlContents: null, scripts: [] }); let staticHtml = ''; staticHtml = data.template ? data.template : await getPageTemplate(staticHtml, compilation.context, template, []); - // console.log('+ page template', { staticHtml }); - staticHtml = await getAppTemplate(staticHtml, compilation.context, imports, [], false, title); - // console.log('+ app template', { staticHtml }); - staticHtml = await getUserScripts(staticHtml, compilation.context); - // console.log('+ user scripts', { staticHtml }); - - // TODO do we want to use http:// here for optimizer? staticHtml = await (await htmlOptimizer.optimize(new URL(`http://localhost:8080${route}`), new Response(staticHtml))).text(); - // console.log('+ optimizer', { staticHtml }); // better way to write out this inline code? - // TODO does executeRouteModule need to get bundled? - // TODO do we need to bundle this too since we reference executeModuleUrl.href directly? await fs.writeFile(entryFileUrl, ` import { executeRouteModule } from '${normalizePathnameForWindows(executeModuleUrl)}'; @@ -246,7 +236,6 @@ async function bundleSsrPages(compilation) { const [rollupConfig] = await getRollupConfigForSsr(compilation, input); - // TODO do we need templates anymore? if (rollupConfig.input.length > 0) { const bundle = await rollup(rollupConfig); await bundle.write(rollupConfig.output); diff --git a/packages/cli/src/lifecycles/prerender.js b/packages/cli/src/lifecycles/prerender.js index ff183fa9e..8d922f400 100644 --- a/packages/cli/src/lifecycles/prerender.js +++ b/packages/cli/src/lifecycles/prerender.js @@ -55,7 +55,6 @@ async function preRenderCompilationWorker(compilation, workerPrerender) { console.info('pages to generate', `\n ${pages.map(page => page.route).join('\n ')}`); - console.log({ workerPrerender }); const pool = new WorkerPool(os.cpus().length, new URL('../lib/ssr-route-worker.js', import.meta.url)); for (const page of pages) { diff --git a/packages/cli/src/plugins/resource/plugin-standard-html.js b/packages/cli/src/plugins/resource/plugin-standard-html.js index 11f81d1e6..d1a676691 100644 --- a/packages/cli/src/plugins/resource/plugin-standard-html.js +++ b/packages/cli/src/plugins/resource/plugin-standard-html.js @@ -213,7 +213,6 @@ class StandardHtmlResource extends ResourceInterface { } async shouldOptimize(url, response) { - // TOOD should be .indexOf(this.contentType) === 0 return response.headers.get('Content-Type').indexOf(this.contentType) >= 0; }