diff --git a/greenwood.config.js b/greenwood.config.js index becad0fe5..332980001 100644 --- a/greenwood.config.js +++ b/greenwood.config.js @@ -4,7 +4,7 @@ import { greenwoodPluginImportCss } from '@greenwood/plugin-import-css'; import { greenwoodPluginImportJson } from '@greenwood/plugin-import-json'; import { greenwoodPluginPolyfills } from '@greenwood/plugin-polyfills'; import { greenwoodPluginPostCss } from '@greenwood/plugin-postcss'; -// import { greenwoodPluginRendererPuppeteer } from '@greenwood/plugin-renderer-puppeteer'; +import { greenwoodPluginRendererPuppeteer } from '@greenwood/plugin-renderer-puppeteer'; import rollupPluginAnalyzer from 'rollup-plugin-analyzer'; import { fileURLToPath, URL } from 'url'; @@ -34,8 +34,8 @@ export default { ]; } }, - greenwoodPluginIncludeHTML() - // greenwoodPluginRendererPuppeteer() // can only have one renderer at a time + greenwoodPluginIncludeHTML(), + greenwoodPluginRendererPuppeteer() ], markdown: { plugins: [ diff --git a/package.json b/package.json index ce23632f6..c88ecd994 100644 --- a/package.json +++ b/package.json @@ -17,9 +17,9 @@ "lerna": "lerna", "clean": "rimraf ./**/.greenwood/** && rimraf ./**/public/** && rimraf ./coverage", "clean:deps": "rimraf **/node_modules/**", - "build": "cross-env __GWD_ROLLUP_MODE__=strict node --experimental-loader ./node_modules/@greenwood/cli/src/loader.js . build", - "serve": "node --experimental-loader ./node_modules/@greenwood/cli/src/loader.js . serve", - "develop": "node --experimental-loader ./node_modules/@greenwood/cli/src/loader.js . develop", + "build": "cross-env __GWD_ROLLUP_MODE__=strict node --experimental-loader ./packages/cli/src/loader.js . build", + "serve": "node --experimental-loader ./packages/cli/src/loader.js . serve", + "develop": "node --experimental-loader ./packages/cli/src/loader.js . develop", "test": "cross-env BROWSERSLIST_IGNORE_OLD_DATA=true __GWD_ROLLUP_MODE__=strict c8 mocha", "test:tdd": "yarn test --watch", "lint:js": "eslint \"*.js\" \"./packages/**/**/*.js\" \"./test/*.js\" \"./www/**/**/*.js\"", diff --git a/packages/cli/src/config/rollup.config.js b/packages/cli/src/config/rollup.config.js index 06ca8248b..0e08c44de 100644 --- a/packages/cli/src/config/rollup.config.js +++ b/packages/cli/src/config/rollup.config.js @@ -25,12 +25,13 @@ function greenwoodResourceLoader (compilation) { const extension = path.extname(importAsIdAsUrl); if (extension !== '.js') { + const originalUrl = `${id}?type=${extension.replace('.', '')}`; let contents; for (const plugin of resourcePlugins) { const headers = { request: { - originalUrl: id + originalUrl }, response: { 'content-type': plugin.contentType diff --git a/packages/cli/src/loader.js b/packages/cli/src/loader.js index cc77cc5c5..0f1c621fc 100644 --- a/packages/cli/src/loader.js +++ b/packages/cli/src/loader.js @@ -18,25 +18,20 @@ function getCustomLoaderPlugins(url, body, headers) { export function resolve(specifier, context, defaultResolve) { const { parentURL = baseURL } = context; - console.debug('RESOLVE', specifier); if (getCustomLoaderPlugins(specifier).length > 0) { - console.debug('===> use custom resolve', new URL(specifier, parentURL).href); return { url: new URL(specifier, parentURL).href }; } - console.debug('===> use default resolve'); return defaultResolve(specifier, context, defaultResolve); } export async function load(source, context, defaultLoad) { - console.debug('###### LOAD'); const resourcePlugins = getCustomLoaderPlugins(source); if (resourcePlugins.length) { - console.debug('===> use custom load', source); const headers = { request: { originalUrl: `${source}?type=${path.extname(source).replace('.', '')}`, @@ -45,27 +40,23 @@ export async function load(source, context, defaultLoad) { }; let contents = ''; - console.debug('111111', contents); for (const plugin of resourcePlugins) { if (await plugin.shouldServe(source, headers)) { contents = (await plugin.serve(source, headers)).body || contents; } } - console.debug('222222', contents); for (const plugin of resourcePlugins) { if (await plugin.shouldIntercept(fileURLToPath(source), contents, headers)) { contents = (await plugin.intercept(fileURLToPath(source), contents, headers)).body || contents; } } - console.debug('@@@@@@@@@', { contents }); return { format: 'module', source: contents }; } - console.debug('===> use default load', source); return defaultLoad(source, context, defaultLoad); } \ No newline at end of file