diff --git a/greenwood.config.js b/greenwood.config.js
index 73fc49abb..648fdc361 100644
--- a/greenwood.config.js
+++ b/greenwood.config.js
@@ -14,7 +14,9 @@ export default {
interpolateFrontmatter: true,
plugins: [
greenwoodPluginGraphQL(),
- greenwoodPluginPolyfills(),
+ greenwoodPluginPolyfills({
+ lit: true
+ }),
greenwoodPluginPostCss(),
greenwoodPluginImportJson(),
greenwoodPluginImportCss(),
diff --git a/package.json b/package.json
index 71518641b..fe99893d8 100644
--- a/package.json
+++ b/package.json
@@ -30,7 +30,7 @@
"lint": "ls-lint && yarn lint:js && yarn lint:ts && yarn lint:css"
},
"resolutions": {
- "lit": "^2.1.1"
+ "lit": "^3.1.0"
},
"devDependencies": {
"@ls-lint/ls-lint": "^1.10.0",
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 3298bb85c..8bb492765 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -52,7 +52,7 @@
"remark-rehype": "^7.0.0",
"rollup": "^3.29.4",
"unified": "^9.2.0",
- "wc-compiler": "~0.11.0"
+ "wc-compiler": "~0.12.0"
},
"devDependencies": {
"@babel/runtime": "^7.10.4",
@@ -62,7 +62,7 @@
"@material/mwc-button": "^0.25.2",
"@stencil/core": "^2.12.0",
"@types/trusted-types": "^2.0.2",
- "lit": "^2.0.0",
+ "lit": "^3.1.0",
"lit-redux-router": "~0.20.0",
"lodash-es": "^4.17.20",
"postcss-nested": "^4.1.2",
diff --git a/packages/cli/src/config/rollup.config.js b/packages/cli/src/config/rollup.config.js
index 8aa6f56c2..53fa89845 100644
--- a/packages/cli/src/config/rollup.config.js
+++ b/packages/cli/src/config/rollup.config.js
@@ -6,30 +6,11 @@ import commonjs from '@rollup/plugin-commonjs';
import * as walk from 'acorn-walk';
// https://github.com/rollup/rollup/issues/2121
+// would be nice to get rid of this
function cleanRollupId(id) {
return id.replace('\x00', '');
}
-// specifically to handle escodegen and other node modules
-// using require for package.json or other json files
-// https://github.com/estools/escodegen/issues/455
-function greenwoodJsonLoader() {
- return {
- name: 'greenwood-json-loader',
- async load(id) {
- const idUrl = new URL(`file://${cleanRollupId(id)}`);
- const extension = idUrl.pathname.split('.').pop();
-
- if (extension === 'json') {
- const json = JSON.parse(await fs.promises.readFile(idUrl, 'utf-8'));
- const contents = `export default ${JSON.stringify(json)}`;
-
- return contents;
- }
- }
- };
-}
-
function greenwoodResourceLoader (compilation) {
const resourcePlugins = compilation.config.plugins.filter((plugin) => {
return plugin.type === 'resource';
@@ -373,9 +354,14 @@ const getRollupConfigForApis = async (compilation) => {
chunkFileNames: '[name].[hash].js'
},
plugins: [
- greenwoodJsonLoader(),
greenwoodResourceLoader(compilation),
- nodeResolve(),
+ // support node export conditions for API routes
+ // https://github.com/ProjectEvergreen/greenwood/issues/1118
+ // https://github.com/rollup/plugins/issues/362#issuecomment-873448461
+ nodeResolve({
+ exportConditions: ['node'],
+ preferBuiltins: true
+ }),
commonjs(),
greenwoodImportMetaUrl(compilation)
]
@@ -395,12 +381,12 @@ const getRollupConfigForSsr = async (compilation, input) => {
chunkFileNames: '[name].[hash].js'
},
plugins: [
- greenwoodJsonLoader(),
greenwoodResourceLoader(compilation),
- // TODO let this through for lit to enable nodeResolve({ preferBuiltins: true })
- // https://github.com/lit/lit/issues/449
+ // support node export conditions for SSR pages
// https://github.com/ProjectEvergreen/greenwood/issues/1118
+ // https://github.com/rollup/plugins/issues/362#issuecomment-873448461
nodeResolve({
+ exportConditions: ['node'],
preferBuiltins: true
}),
commonjs(),
diff --git a/packages/cli/src/lib/resource-utils.js b/packages/cli/src/lib/resource-utils.js
index a3d71e579..1032afc5e 100644
--- a/packages/cli/src/lib/resource-utils.js
+++ b/packages/cli/src/lib/resource-utils.js
@@ -124,7 +124,8 @@ async function trackResourcesForRoute(html, compilation, route) {
const scripts = await Promise.all(root.querySelectorAll('script')
.filter(script => (
isLocalLink(script.getAttribute('src')) || script.rawText)
- && script.rawAttrs.indexOf('importmap') < 0)
+ && script.rawAttrs.indexOf('importmap') < 0
+ && script.getAttribute('type') !== 'application/json')
.map(async(script) => {
const src = script.getAttribute('src');
const optimizationAttr = script.getAttribute('data-gwd-opt');
diff --git a/packages/cli/src/lib/templating-utils.js b/packages/cli/src/lib/templating-utils.js
index 9503e6aac..f9e83b771 100644
--- a/packages/cli/src/lib/templating-utils.js
+++ b/packages/cli/src/lib/templating-utils.js
@@ -1,7 +1,6 @@
import fs from 'fs/promises';
import htmlparser from 'node-html-parser';
import { checkResourceExists } from './resource-utils.js';
-import { getPackageJson } from './node-modules-utils.js';
async function getCustomPageTemplatesFromPlugins(contextPlugins, templateName) {
const customTemplateLocations = [];
@@ -177,7 +176,7 @@ async function getAppTemplate(pageTemplateContents, context, customImports = [],
}
async function getUserScripts (contents, compilation) {
- const { context, config } = compilation;
+ const { config } = compilation;
contents = contents.replace('
', `
@@ -186,22 +185,6 @@ async function getUserScripts (contents, compilation) {
`);
- // TODO get rid of lit polyfills in core
- // https://github.com/ProjectEvergreen/greenwood/issues/728
- // https://lit.dev/docs/tools/requirements/#polyfills
- if (process.env.__GWD_COMMAND__ === 'build') { // eslint-disable-line no-underscore-dangle
- const userPackageJson = await getPackageJson(context);
- const dependencies = userPackageJson?.dependencies || {};
- const litPolyfill = dependencies && dependencies.lit
- ? '\n'
- : '';
-
- contents = contents.replace('', `
-
- ${litPolyfill}
- `);
- }
-
return contents;
}
diff --git a/packages/cli/src/lifecycles/bundle.js b/packages/cli/src/lifecycles/bundle.js
index e5a28fdd5..22f96cca4 100644
--- a/packages/cli/src/lifecycles/bundle.js
+++ b/packages/cli/src/lifecycles/bundle.js
@@ -7,6 +7,28 @@ import { checkResourceExists, mergeResponse, normalizePathnameForWindows } from
import path from 'path';
import { rollup } from 'rollup';
+async function interceptPage(url, request, plugins, body) {
+ let response = new Response(body, {
+ headers: new Headers({ 'Content-Type': 'text/html' })
+ });
+
+ for (const plugin of plugins) {
+ if (plugin.shouldIntercept && await plugin.shouldIntercept(url, request, response)) {
+ response = await plugin.intercept(url, request, response);
+ }
+ }
+
+ return response;
+}
+
+function getPluginInstances(compilation) {
+ return [...compilation.config.plugins]
+ .filter(plugin => plugin.type === 'resource' && plugin.name !== 'plugin-node-modules:resource')
+ .map((plugin) => {
+ return plugin.provider(compilation);
+ });
+}
+
async function emitResources(compilation) {
const { outputDir } = compilation.context;
const { resources, graph } = compilation;
@@ -202,6 +224,7 @@ async function bundleSsrPages(compilation) {
staticHtml = data.template ? data.template : await getPageTemplate(staticHtml, compilation.context, template, []);
staticHtml = await getAppTemplate(staticHtml, compilation.context, imports, [], false, title);
staticHtml = await getUserScripts(staticHtml, compilation);
+ staticHtml = await (await interceptPage(new URL(`http://localhost:8080${route}`), new Request(new URL(`http://localhost:8080${route}`)), getPluginInstances(compilation), staticHtml)).text();
staticHtml = await (await htmlOptimizer.optimize(new URL(`http://localhost:8080${route}`), new Response(staticHtml))).text();
staticHtml = staticHtml.replace(/[`\\$]/g, '\\$&'); // https://stackoverflow.com/a/75688937/417806
diff --git a/packages/cli/src/lifecycles/graph.js b/packages/cli/src/lifecycles/graph.js
index 557d6c0f9..227c87a78 100644
--- a/packages/cli/src/lifecycles/graph.js
+++ b/packages/cli/src/lifecycles/graph.js
@@ -51,6 +51,7 @@ const generateGraph = async (compilation) => {
let filePath;
let prerender = true;
let isolation = false;
+ let hydration = false;
/*
* check if additional nested directories exist to correctly determine route (minus filename)
@@ -132,8 +133,9 @@ const generateGraph = async (compilation) => {
const request = await requestAsObject(new Request(filenameUrl));
worker.on('message', async (result) => {
- prerender = result.prerender;
+ prerender = result.prerender ?? false;
isolation = result.isolation ?? isolation;
+ hydration = result.hydration ?? hydration;
if (result.frontmatter) {
result.frontmatter.imports = result.frontmatter.imports || [];
@@ -203,8 +205,9 @@ const generateGraph = async (compilation) => {
* template: page template to use as a base for a generated component
* title: a default value that can be used for
* isSSR: if this is a server side route
- * prerednder: if this should be statically exported
+ * prerender: if this should be statically exported
* isolation: if this should be run in isolated mode
+ * hydration: if this page needs hydration support
*/
pages.push({
data: customData || {},
@@ -225,7 +228,8 @@ const generateGraph = async (compilation) => {
title,
isSSR: !isStatic,
prerender,
- isolation
+ isolation,
+ hydration
});
}
}
diff --git a/packages/cli/src/plugins/resource/plugin-standard-html.js b/packages/cli/src/plugins/resource/plugin-standard-html.js
index 8f0622545..cf3c1cff2 100644
--- a/packages/cli/src/plugins/resource/plugin-standard-html.js
+++ b/packages/cli/src/plugins/resource/plugin-standard-html.js
@@ -115,6 +115,7 @@ class StandardHtmlResource extends ResourceInterface {
if (result.template) {
ssrTemplate = result.template;
}
+
if (result.body) {
ssrBody = result.body;
}
diff --git a/packages/cli/test/cases/build.default.import-node-modules/build.default.import-node-modules.spec.js b/packages/cli/test/cases/build.default.import-node-modules/build.default.import-node-modules.spec.js
index 736d93df5..6f89c6466 100644
--- a/packages/cli/test/cases/build.default.import-node-modules/build.default.import-node-modules.spec.js
+++ b/packages/cli/test/cases/build.default.import-node-modules/build.default.import-node-modules.spec.js
@@ -217,9 +217,8 @@ describe('Build Greenwood With: ', function() {
expect(mainScriptTags.length).to.be.equal(1);
});
- // TODO clean up lit-polyfill as part of https://github.com/ProjectEvergreen/greenwood/issues/728
it('should have the total expected number of .js file in the output directory', async function() {
- expect(await glob.promise(path.join(this.context.publicDir, '*.js'))).to.have.lengthOf(4);
+ expect(await glob.promise(path.join(this.context.publicDir, '*.js'))).to.have.lengthOf(3);
});
it('should have the expected main.js file in the output directory', async function() {
@@ -242,7 +241,7 @@ describe('Build Greenwood With: ', function() {
const inlineScriptTag = Array.from(dom.window.document.querySelectorAll('head > script:not([src])')).filter(tag => !tag.getAttribute('data-gwd'))[0];
expect(inlineScriptTag.textContent.replace(/\n/g, '')).to
- .equal('import"/116321042.262925e6.js";import"/lit-html.71ac31d8.js";//# sourceMappingURL=116321042.f667a8c7.js.map');
+ .equal('import"/116321042.4f3171e3.js";import"/lit-html.31ea57aa.js";//# sourceMappingURL=116321042.69f46fc1.js.map');
});
});
diff --git a/packages/cli/test/cases/build.default.import-node-modules/package.json b/packages/cli/test/cases/build.default.import-node-modules/package.json
index a280755e3..bf0c8c424 100644
--- a/packages/cli/test/cases/build.default.import-node-modules/package.json
+++ b/packages/cli/test/cases/build.default.import-node-modules/package.json
@@ -2,7 +2,7 @@
"name": "test-import-node-modules",
"type": "module",
"dependencies": {
- "lit": "^2.0.0",
+ "lit": "^3.1.0",
"lodash-es": "^4.17.20",
"prismjs": "^1.21.0",
"pwa-helpers": "^0.9.1",
diff --git a/packages/cli/test/cases/build.default.spa/build.default.spa.spec.js b/packages/cli/test/cases/build.default.spa/build.default.spa.spec.js
index 0905ab808..334895120 100644
--- a/packages/cli/test/cases/build.default.spa/build.default.spa.spec.js
+++ b/packages/cli/test/cases/build.default.spa/build.default.spa.spec.js
@@ -235,8 +235,7 @@ describe('Build Greenwood With: ', function() {
// one for the footer.js
// one for index.js
// one for lit element bundle
- // TODO clean up lit-polyfill as part of https://github.com/ProjectEvergreen/greenwood/issues/728
- expect(jsFiles.length).to.be.equal(6);
+ expect(jsFiles.length).to.be.equal(5);
});
it('should have custom tag in the ', function() {
diff --git a/packages/cli/test/cases/build.default.spa/package.json b/packages/cli/test/cases/build.default.spa/package.json
index bc59f2ff5..e8f6bae6e 100644
--- a/packages/cli/test/cases/build.default.spa/package.json
+++ b/packages/cli/test/cases/build.default.spa/package.json
@@ -1,7 +1,7 @@
{
"type": "module",
"dependencies": {
- "lit": "^2.0.0",
+ "lit": "^3.1.0",
"lit-redux-router": "~0.20.0",
"pwa-helpers": "^0.9.1",
"redux": "^4.0.5",
diff --git a/packages/cli/test/cases/build.default.ssr-static-export/build.default.ssr-static-export.spec.js b/packages/cli/test/cases/build.default.ssr-static-export/build.default.ssr-static-export.spec.js
index 71582d099..566348c5c 100644
--- a/packages/cli/test/cases/build.default.ssr-static-export/build.default.ssr-static-export.spec.js
+++ b/packages/cli/test/cases/build.default.ssr-static-export/build.default.ssr-static-export.spec.js
@@ -147,11 +147,10 @@ describe('Build Greenwood With: ', function() {
expect(styles.length).to.equal(1);
});
- // TODO clean up lit-polyfill as part of https://github.com/ProjectEvergreen/greenwood/issues/728
it('should have four script tags', function() {
const scripts = Array.from(dom.window.document.querySelectorAll('head > script')).filter(tag => !tag.getAttribute('data-gwd'));
- expect(scripts.length).to.equal(4);
+ expect(scripts.length).to.equal(3);
});
it('should have expected SSR content from the non module script tag', function() {
diff --git a/packages/cli/test/cases/build.default.ssr-static-export/package.json b/packages/cli/test/cases/build.default.ssr-static-export/package.json
index 2dee3e768..0b8c2d82a 100644
--- a/packages/cli/test/cases/build.default.ssr-static-export/package.json
+++ b/packages/cli/test/cases/build.default.ssr-static-export/package.json
@@ -1,6 +1,6 @@
{
"type": "module",
"dependencies": {
- "lit": "^2.0.0"
+ "lit": "^3.1.0"
}
}
\ No newline at end of file
diff --git a/packages/cli/test/cases/develop.default/develop.default.spec.js b/packages/cli/test/cases/develop.default/develop.default.spec.js
index 8c3cf16e2..3958267f5 100644
--- a/packages/cli/test/cases/develop.default/develop.default.spec.js
+++ b/packages/cli/test/cases/develop.default/develop.default.spec.js
@@ -101,6 +101,10 @@ describe('Develop Greenwood With: ', function() {
`${process.cwd()}/node_modules/lit/package.json`,
`${outputPath}/node_modules/lit/`
);
+ const litSsrPackageJson = await getDependencyFiles(
+ `${process.cwd()}/node_modules/@lit-labs/ssr-dom-shim/package.json`,
+ `${outputPath}/node_modules/@lit-labs/ssr-dom-shim/`
+ );
const litElement = await getDependencyFiles(
`${process.cwd()}/node_modules/lit-element/*.js`,
`${outputPath}/node_modules/lit-element/`
@@ -379,6 +383,7 @@ describe('Develop Greenwood With: ', function() {
...getSetupFiles(outputPath),
...lit,
...litPackageJson,
+ ...litSsrPackageJson,
...litDirectives,
...litDecorators,
...litElementPackageJson,
diff --git a/packages/cli/test/cases/develop.default/import-map.snapshot.json b/packages/cli/test/cases/develop.default/import-map.snapshot.json
index ad256ef39..4e5f60629 100644
--- a/packages/cli/test/cases/develop.default/import-map.snapshot.json
+++ b/packages/cli/test/cases/develop.default/import-map.snapshot.json
@@ -235,10 +235,6 @@
"lit-html/directives/unsafe-svg.js": "/node_modules/lit-html/directives/unsafe-svg.js",
"lit/directives/unsafe-svg.js": "/node_modules/lit/directives/unsafe-svg.js",
"lit-html/directives/until.js": "/node_modules/lit-html/directives/until.js",
- "lit-element/experimental-hydrate-support.js": "/node_modules/lit-element/experimental-hydrate-support.js",
- "lit/experimental-hydrate-support.js": "/node_modules/lit/experimental-hydrate-support.js",
- "lit-html/experimental-hydrate.js": "/node_modules/lit-html/experimental-hydrate.js",
- "lit/experimental-hydrate.js": "/node_modules/lit/experimental-hydrate.js",
"lit/html.js": "/node_modules/lit/html.js",
"lit/polyfill-support.js": "/node_modules/lit/polyfill-support.js",
"lit-html/static.js": "/node_modules/lit-html/static.js",
diff --git a/packages/cli/test/cases/develop.default/package.json b/packages/cli/test/cases/develop.default/package.json
index cb0f93aca..b3fda5ee7 100644
--- a/packages/cli/test/cases/develop.default/package.json
+++ b/packages/cli/test/cases/develop.default/package.json
@@ -8,6 +8,6 @@
"@material/mwc-button": "^0.25.2",
"@stencil/core": "^2.12.0",
"@types/trusted-types": "^2.0.2",
- "lit": "^2.0.0"
+ "lit": "^3.1.0"
}
}
\ No newline at end of file
diff --git a/packages/cli/test/cases/develop.ssr/develop.ssr.spec.js b/packages/cli/test/cases/develop.ssr/develop.ssr.spec.js
index 4f7919f66..4eef144f6 100644
--- a/packages/cli/test/cases/develop.ssr/develop.ssr.spec.js
+++ b/packages/cli/test/cases/develop.ssr/develop.ssr.spec.js
@@ -64,6 +64,10 @@ describe('Develop Greenwood With: ', function() {
`${process.cwd()}/node_modules/lit/package.json`,
`${outputPath}/node_modules/lit/`
);
+ const litSsrPackageJson = await getDependencyFiles(
+ `${process.cwd()}/node_modules/@lit-labs/ssr-dom-shim/package.json`,
+ `${outputPath}/node_modules/@lit-labs/ssr-dom-shim/`
+ );
const litElement = await getDependencyFiles(
`${process.cwd()}/node_modules/lit-element/*.js`,
`${outputPath}/node_modules/lit-element/`
@@ -111,6 +115,7 @@ describe('Develop Greenwood With: ', function() {
...getSetupFiles(outputPath),
...lit,
...litPackageJson,
+ ...litSsrPackageJson,
...litDirectives,
...litDecorators,
...litElementPackageJson,
diff --git a/packages/cli/test/cases/develop.ssr/package.json b/packages/cli/test/cases/develop.ssr/package.json
index 2dee3e768..0b8c2d82a 100644
--- a/packages/cli/test/cases/develop.ssr/package.json
+++ b/packages/cli/test/cases/develop.ssr/package.json
@@ -1,6 +1,6 @@
{
"type": "module",
"dependencies": {
- "lit": "^2.0.0"
+ "lit": "^3.1.0"
}
}
\ No newline at end of file
diff --git a/packages/cli/test/cases/serve.default.ssr-static-export/package.json b/packages/cli/test/cases/serve.default.ssr-static-export/package.json
index 2dee3e768..0b8c2d82a 100644
--- a/packages/cli/test/cases/serve.default.ssr-static-export/package.json
+++ b/packages/cli/test/cases/serve.default.ssr-static-export/package.json
@@ -1,6 +1,6 @@
{
"type": "module",
"dependencies": {
- "lit": "^2.0.0"
+ "lit": "^3.1.0"
}
}
\ No newline at end of file
diff --git a/packages/cli/test/cases/serve.default.ssr-static-export/serve.default.ssr-static-export.spec.js b/packages/cli/test/cases/serve.default.ssr-static-export/serve.default.ssr-static-export.spec.js
index 26fa97766..117e6ed62 100644
--- a/packages/cli/test/cases/serve.default.ssr-static-export/serve.default.ssr-static-export.spec.js
+++ b/packages/cli/test/cases/serve.default.ssr-static-export/serve.default.ssr-static-export.spec.js
@@ -175,11 +175,10 @@ describe('Serve Greenwood With: ', function() {
expect(styles.length).to.equal(1);
});
- // TODO clean up lit-polyfill as part of https://github.com/ProjectEvergreen/greenwood/issues/728
it('should have four script tags', function() {
const scripts = Array.from(dom.window.document.querySelectorAll('head script')).filter(tag => !tag.getAttribute('data-gwd'));
- expect(scripts.length).to.equal(4);
+ expect(scripts.length).to.equal(3);
});
it('should have expected SSR content from the non module script tag', function() {
diff --git a/packages/plugin-graphql/test/cases/query-children/package.json b/packages/plugin-graphql/test/cases/query-children/package.json
index 9b235502e..225becaa2 100644
--- a/packages/plugin-graphql/test/cases/query-children/package.json
+++ b/packages/plugin-graphql/test/cases/query-children/package.json
@@ -2,6 +2,6 @@
"name": "plugin-graphql-test-children-query",
"type": "module",
"dependencies": {
- "lit": "^2.0.0"
+ "lit": "^3.1.0"
}
}
\ No newline at end of file
diff --git a/packages/plugin-graphql/test/cases/query-children/query-children.spec.js b/packages/plugin-graphql/test/cases/query-children/query-children.spec.js
index 65df87110..20c5793f8 100644
--- a/packages/plugin-graphql/test/cases/query-children/query-children.spec.js
+++ b/packages/plugin-graphql/test/cases/query-children/query-children.spec.js
@@ -77,6 +77,10 @@ describe('Build Greenwood With: ', function() {
`${process.cwd()}/node_modules/lit/package.json`,
`${outputPath}/node_modules/lit/`
);
+ const litSsrPackageJson = await getDependencyFiles(
+ `${process.cwd()}/node_modules/@lit-labs/ssr-dom-shim/package.json`,
+ `${outputPath}/node_modules/@lit-labs/ssr-dom-shim/`
+ );
const litElement = await getDependencyFiles(
`${process.cwd()}/node_modules/lit-element/*.js`,
`${outputPath}/node_modules/lit-element/`
@@ -126,6 +130,7 @@ describe('Build Greenwood With: ', function() {
...greenwoodGraphqlQueryLibs,
...lit,
...litPackageJson,
+ ...litSsrPackageJson,
...litDirectives,
...litDecorators,
...litElementPackageJson,
diff --git a/packages/plugin-graphql/test/cases/query-custom-frontmatter/package.json b/packages/plugin-graphql/test/cases/query-custom-frontmatter/package.json
index 83511be89..e9e9ceab1 100644
--- a/packages/plugin-graphql/test/cases/query-custom-frontmatter/package.json
+++ b/packages/plugin-graphql/test/cases/query-custom-frontmatter/package.json
@@ -2,6 +2,6 @@
"name": "plugin-graphql-test-query-custom-frontmatter",
"type": "module",
"dependencies": {
- "lit": "^2.0.0"
+ "lit": "^3.1.0"
}
}
\ No newline at end of file
diff --git a/packages/plugin-graphql/test/cases/query-custom-frontmatter/query-custom-frontmatter.spec.js b/packages/plugin-graphql/test/cases/query-custom-frontmatter/query-custom-frontmatter.spec.js
index c4a3a620e..967f4de86 100644
--- a/packages/plugin-graphql/test/cases/query-custom-frontmatter/query-custom-frontmatter.spec.js
+++ b/packages/plugin-graphql/test/cases/query-custom-frontmatter/query-custom-frontmatter.spec.js
@@ -79,6 +79,10 @@ describe('Build Greenwood With: ', function() {
`${process.cwd()}/node_modules/lit/package.json`,
`${outputPath}/node_modules/lit/`
);
+ const litSsrPackageJson = await getDependencyFiles(
+ `${process.cwd()}/node_modules/@lit-labs/ssr-dom-shim/package.json`,
+ `${outputPath}/node_modules/@lit-labs/ssr-dom-shim/`
+ );
const litElement = await getDependencyFiles(
`${process.cwd()}/node_modules/lit-element/*.js`,
`${outputPath}/node_modules/lit-element/`
@@ -128,6 +132,7 @@ describe('Build Greenwood With: ', function() {
...greenwoodGraphqlQueryLibs,
...lit,
...litPackageJson,
+ ...litSsrPackageJson,
...litDirectives,
...litDecorators,
...litElementPackageJson,
diff --git a/packages/plugin-graphql/test/cases/query-graph/package.json b/packages/plugin-graphql/test/cases/query-graph/package.json
index 5a64a7a74..27178da74 100644
--- a/packages/plugin-graphql/test/cases/query-graph/package.json
+++ b/packages/plugin-graphql/test/cases/query-graph/package.json
@@ -2,6 +2,6 @@
"name": "plugin-graphql-test-graph-query",
"type": "module",
"dependencies": {
- "lit": "^2.0.0"
+ "lit": "^3.1.0"
}
}
\ No newline at end of file
diff --git a/packages/plugin-graphql/test/cases/query-graph/query-graph.spec.js b/packages/plugin-graphql/test/cases/query-graph/query-graph.spec.js
index 43d20a5d0..11209a801 100644
--- a/packages/plugin-graphql/test/cases/query-graph/query-graph.spec.js
+++ b/packages/plugin-graphql/test/cases/query-graph/query-graph.spec.js
@@ -75,6 +75,10 @@ describe('Build Greenwood With: ', function() {
`${process.cwd()}/node_modules/lit/package.json`,
`${outputPath}/node_modules/lit/`
);
+ const litSsrPackageJson = await getDependencyFiles(
+ `${process.cwd()}/node_modules/@lit-labs/ssr-dom-shim/package.json`,
+ `${outputPath}/node_modules/@lit-labs/ssr-dom-shim/`
+ );
const litElement = await getDependencyFiles(
`${process.cwd()}/node_modules/lit-element/*.js`,
`${outputPath}/node_modules/lit-element/`
@@ -124,6 +128,7 @@ describe('Build Greenwood With: ', function() {
...greenwoodGraphqlQueryLibs,
...lit,
...litPackageJson,
+ ...litSsrPackageJson,
...litDirectives,
...litDecorators,
...litElementPackageJson,
diff --git a/packages/plugin-graphql/test/cases/query-menu/package.json b/packages/plugin-graphql/test/cases/query-menu/package.json
index cf01e2bba..3d07f5b69 100644
--- a/packages/plugin-graphql/test/cases/query-menu/package.json
+++ b/packages/plugin-graphql/test/cases/query-menu/package.json
@@ -2,6 +2,6 @@
"name": "plugin-graphql-test-menu-query",
"type": "module",
"dependencies": {
- "lit": "^2.0.0"
+ "lit": "^3.1.0"
}
}
\ No newline at end of file
diff --git a/packages/plugin-graphql/test/cases/query-menu/query-menu.spec.js b/packages/plugin-graphql/test/cases/query-menu/query-menu.spec.js
index ffe69c7f6..0d3df4ca6 100644
--- a/packages/plugin-graphql/test/cases/query-menu/query-menu.spec.js
+++ b/packages/plugin-graphql/test/cases/query-menu/query-menu.spec.js
@@ -77,6 +77,10 @@ describe('Build Greenwood With: ', async function() {
`${process.cwd()}/node_modules/lit/package.json`,
`${outputPath}/node_modules/lit/`
);
+ const litSsrPackageJson = await getDependencyFiles(
+ `${process.cwd()}/node_modules/@lit-labs/ssr-dom-shim/package.json`,
+ `${outputPath}/node_modules/@lit-labs/ssr-dom-shim/`
+ );
const litElement = await getDependencyFiles(
`${process.cwd()}/node_modules/lit-element/*.js`,
`${outputPath}/node_modules/lit-element/`
@@ -126,6 +130,7 @@ describe('Build Greenwood With: ', async function() {
...greenwoodGraphqlQueryLibs,
...lit,
...litPackageJson,
+ ...litSsrPackageJson,
...litDirectives,
...litDecorators,
...litElementPackageJson,
diff --git a/packages/plugin-import-jsx/package.json b/packages/plugin-import-jsx/package.json
index f9f4e08d5..382bddd52 100644
--- a/packages/plugin-import-jsx/package.json
+++ b/packages/plugin-import-jsx/package.json
@@ -27,7 +27,7 @@
"@greenwood/cli": "^0.28.0-alpha.4"
},
"dependencies": {
- "wc-compiler": "~0.11.0"
+ "wc-compiler": "~0.12.0"
},
"devDependencies": {
"@greenwood/cli": "^0.29.2"
diff --git a/packages/plugin-polyfills/test/cases/lit/lit.spec.js b/packages/plugin-polyfills/test/cases/lit/lit.spec.js
index 13f39990c..2ba1855f5 100644
--- a/packages/plugin-polyfills/test/cases/lit/lit.spec.js
+++ b/packages/plugin-polyfills/test/cases/lit/lit.spec.js
@@ -139,15 +139,13 @@ describe('Build Greenwood With: ', function() {
dom = await JSDOM.fromFile(path.resolve(this.context.publicDir, 'index.html'));
});
- // TODO need to reconcile how this lit polyfilling is working since the CLI already adds it?
- // related to https://github.com/ProjectEvergreen/greenwood/issues/728
it('should have one
+ `);
+
+ return new Response(body);
+ }
+}
+
const greenwoodPluginRendererLit = (options = {}) => {
- return {
+ return [{
type: 'renderer',
- name: 'plugin-renderer-lit',
+ name: 'plugin-renderer-lit:renderer',
provider: () => {
return {
executeModuleUrl: new URL('./execute-route-module.js', import.meta.url),
prerender: options.prerender
};
}
- };
+ }, {
+ type: 'resource',
+ name: 'plugin-renderer-lit:resource',
+ provider: (compilation, options) => new LitHydrationResource(compilation, options)
+ }];
};
export {
diff --git a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/build.prerender.getting-started.spec.js b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/build.prerender.getting-started.spec.js
index adced6d2c..34ac418e6 100644
--- a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/build.prerender.getting-started.spec.js
+++ b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/build.prerender.getting-started.spec.js
@@ -96,6 +96,10 @@ describe('Build Greenwood With Custom Lit Renderer for SSG prerendering: ', func
`${process.cwd()}/node_modules/lit-html/*.js`,
`${outputPath}/node_modules/lit-html/`
);
+ const litHtmlNode = await getDependencyFiles(
+ `${process.cwd()}/node_modules/lit-html/node/*.js`,
+ `${outputPath}/node_modules/lit-html/node/`
+ );
const litHtmlPackageJson = await getDependencyFiles(
`${process.cwd()}/node_modules/lit-html/package.json`,
`${outputPath}/node_modules/lit-html/`
@@ -116,6 +120,11 @@ describe('Build Greenwood With Custom Lit Renderer for SSG prerendering: ', func
`${process.cwd()}/node_modules/@lit/reactive-element/package.json`,
`${outputPath}/node_modules/@lit/reactive-element/`
);
+ const litReactiveElementNode = await getDependencyFiles(
+ `${process.cwd()}/node_modules/@lit/reactive-element/node/*.js`,
+ `${outputPath}/node_modules/@lit/reactive-element/node/`
+ );
+ // lit-html/node/directives/unsafe-html.js
const litHtmlSourceMap = await getDependencyFiles(
`${process.cwd()}/node_modules/lit-html/lit-html.js.map`,
`${outputPath}/node_modules/lit-html/`
@@ -136,11 +145,13 @@ describe('Build Greenwood With Custom Lit Renderer for SSG prerendering: ', func
...litElementDecorators,
...litHtmlPackageJson,
...litHtml,
+ ...litHtmlNode,
...litHtmlDirectives,
...trustedTypes,
...litReactiveElement,
...litReactiveElementDecorators,
...litReactiveElementPackageJson,
+ ...litReactiveElementNode,
...litHtmlSourceMap
]);
runner.runCommand(cliPath, 'build');
diff --git a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/package.json b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/package.json
index fe421bf5b..c5116ac18 100644
--- a/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/package.json
+++ b/packages/plugin-renderer-lit/test/cases/build.prerender.getting-started/package.json
@@ -2,6 +2,6 @@
"name": "plugin-prerender-lit-build-prerender-getting-started",
"type": "module",
"dependencies": {
- "lit": "^2.1.1"
+ "lit": "^3.1.0"
}
}
\ No newline at end of file
diff --git a/packages/plugin-renderer-lit/test/cases/serve.default/package.json b/packages/plugin-renderer-lit/test/cases/serve.default/package.json
index 15b06e848..bacd51937 100644
--- a/packages/plugin-renderer-lit/test/cases/serve.default/package.json
+++ b/packages/plugin-renderer-lit/test/cases/serve.default/package.json
@@ -2,6 +2,6 @@
"name": "plugin-prerender-lit-build-default",
"type": "module",
"dependencies": {
- "lit": "^2.1.1"
+ "lit": "^3.1.0"
}
}
\ No newline at end of file
diff --git a/packages/plugin-renderer-lit/test/cases/serve.default/serve.default.spec.js b/packages/plugin-renderer-lit/test/cases/serve.default/serve.default.spec.js
index 2f776bc7c..5219f773b 100644
--- a/packages/plugin-renderer-lit/test/cases/serve.default/serve.default.spec.js
+++ b/packages/plugin-renderer-lit/test/cases/serve.default/serve.default.spec.js
@@ -13,8 +13,10 @@
*
* User Workspace
* src/
+ * api/
+ * search.js
* components/
- * counter.js
+ * card.js
* footer.js
* greeting.js
* pages/
@@ -82,6 +84,14 @@ describe('Serve Greenwood With: ', function() {
`${process.cwd()}/node_modules/lit-html/*.js`,
`${outputPath}/node_modules/lit-html/`
);
+ const litHtmlNode = await getDependencyFiles(
+ `${process.cwd()}/node_modules/lit-html/node/*.js`,
+ `${outputPath}/node_modules/lit-html/node/`
+ );
+ const litHtmlNodeDirectives = await getDependencyFiles(
+ `${process.cwd()}/node_modules/lit-html/node/directives/*.js`,
+ `${outputPath}/node_modules/lit-html/node/directives/`
+ );
const litHtmlPackageJson = await getDependencyFiles(
`${process.cwd()}/node_modules/lit-html/package.json`,
`${outputPath}/node_modules/lit-html/`
@@ -100,6 +110,10 @@ describe('Serve Greenwood With: ', function() {
`${process.cwd()}/node_modules/@lit/reactive-element/*.js`,
`${outputPath}/node_modules/@lit/reactive-element/`
);
+ const litReactiveElementNode = await getDependencyFiles(
+ `${process.cwd()}/node_modules/@lit/reactive-element/node/*.js`,
+ `${outputPath}/node_modules/@lit/reactive-element/node/`
+ );
const litReactiveElementDecorators = await getDependencyFiles(
`${process.cwd()}/node_modules/@lit/reactive-element/decorators/*.js`,
`${outputPath}/node_modules/@lit/reactive-element/decorators/`
@@ -108,6 +122,14 @@ describe('Serve Greenwood With: ', function() {
`${process.cwd()}/node_modules/@lit/reactive-element/package.json`,
`${outputPath}/node_modules/@lit/reactive-element/`
);
+ const litSsrElementHydrationSupport = await getDependencyFiles(
+ `${process.cwd()}/node_modules/@lit-labs/ssr-client/lit-element-hydrate-support.js`,
+ `${outputPath}/node_modules/@lit-labs/ssr-client/`
+ );
+ const litSsrHtmlHydrationSupport = await getDependencyFiles(
+ `${process.cwd()}/node_modules/@lit-labs/ssr-client/lib/*.js`,
+ `${outputPath}/node_modules/@lit-labs/ssr-client/lib/`
+ );
runner.setup(outputPath, [
...getSetupFiles(outputPath),
@@ -120,11 +142,16 @@ describe('Serve Greenwood With: ', function() {
...litElementDecorators,
...litHtmlPackageJson,
...litHtml,
+ ...litHtmlNode,
...litHtmlDirectives,
+ ...litHtmlNodeDirectives,
...trustedTypes,
...litReactiveElement,
+ ...litReactiveElementNode,
...litReactiveElementDecorators,
- ...litReactiveElementPackageJson
+ ...litReactiveElementPackageJson,
+ ...litSsrElementHydrationSupport,
+ ...litSsrHtmlHydrationSupport
]);
runner.runCommand(cliPath, 'build');
@@ -160,7 +187,7 @@ describe('Serve Greenwood With: ', function() {
usersPageDom = new JSDOM(usersPageHtml);
});
- describe('Serve command with HTML route response using getBody, getTemplate and getFrontmatter', function() {
+ describe('Serve command with HTML route response using getBody, getTemplate and getFrontmatter for the artists page', function() {
it('should return a 200 status', function() {
expect(response.status).to.equal(200);
@@ -184,15 +211,6 @@ describe('Serve Greenwood With: ', function() {
expect(styles.length).to.equal(1);
});
- // TODO this should be managed via a plugin, not in core
- // https://github.com/ProjectEvergreen/greenwood/issues/728
- it('should have one