Open rlindskog opened 5 years ago
Thanks for reporting. This is due to the code:
'use strict';
const fs = require('fs');
const REPORT_TEMPLATE = fs.readFileSync(__dirname + '/report-template.html', 'utf8');
const REPORT_JAVASCRIPT = [
fs.readFileSync(__dirname + '/renderer/util.js', 'utf8'),
fs.readFileSync(__dirname + '/renderer/dom.js', 'utf8'),
// COMPAT: Remove when Microsoft Edge supports <details>/<summary>
// https://developer.microsoft.com/en-us/microsoft-edge/platform/status/detailssummary/?q=details
fs.readFileSync(require.resolve('details-element-polyfill'), 'utf8'),
fs.readFileSync(__dirname + '/renderer/details-renderer.js', 'utf8'),
fs.readFileSync(__dirname + '/renderer/crc-details-renderer.js', 'utf8'),
fs.readFileSync(__dirname + '/../../lib/file-namer.js', 'utf8'),
fs.readFileSync(__dirname + '/renderer/logger.js', 'utf8'),
fs.readFileSync(__dirname + '/renderer/report-ui-features.js', 'utf8'),
fs.readFileSync(__dirname + '/renderer/category-renderer.js', 'utf8'),
fs.readFileSync(__dirname + '/renderer/performance-category-renderer.js', 'utf8'),
fs.readFileSync(__dirname + '/renderer/pwa-category-renderer.js', 'utf8'),
fs.readFileSync(__dirname + '/renderer/report-renderer.js', 'utf8'),
].join(';\n');
const REPORT_CSS = fs.readFileSync(__dirname + '/report-styles.css', 'utf8');
const REPORT_TEMPLATES = fs.readFileSync(__dirname + '/templates.html', 'utf8');
module.exports = {
REPORT_TEMPLATE,
REPORT_TEMPLATES,
REPORT_JAVASCRIPT,
REPORT_CSS,
};
where require.resolve('details-element-polyfill')
is being rewritten by Webpack into the module number (234
), and thus isn't being supported in the readFile call.
This is effectively a duplicate of https://github.com/zeit/ncc/issues/41, so I'm marking as such and closing.
@rlindskog — Did you ever find a way to work around this?
Reopening as I think there is a way we could support this case specifically.
@danoc I switched to AWS, native node, and @serverless-chrome/lambda temporarily.
Hi! I've made a codebase to help debug the efforts to get Lighthouse working with ncc
and now
:
https://github.com/danoc/now-lighthouse
I also tested out ncc@0.19.0-beta.1
with the latest 4.x
version of Lighthouse. While it does compile, I get this error when it runs:
Unhandled rejection: { Error: Cannot find module "../gather/gatherers/undefined".
at Object.<anonymous> (/var/task/packages/lighthouse/index.js:18627:13)
at __webpack_require__ (/webpack/bootstrap:19:1)
at Function.requireGathererFromPath (/var/task/packages/lighthouse/index.js:20772:63)
at Config.expandGathererShorthand.map.gathererDefn (/var/task/packages/lighthouse/index.js:20818:25)
at Array.map (<anonymous>)
at passes.map.pass (/var/task/packages/lighthouse/index.js:20799:76)
at Array.map (<anonymous>)
at Function.requireGatherers (/var/task/packages/lighthouse/index.js:20798:31)
at new Config (/var/task/packages/lighthouse/index.js:20289:27)
at generateConfig (/var/task/packages/tmp/a590644/node_modules/lighthouse/lighthouse-core/index.js:68:1) code: 'MODULE_NOT_FOUND' }
Haven't been able to dig in further.
Thanks @danoc for the clear replication on this. I'm looking into it.
Ok, Lighthouse support is effectively pending this asset emission feature then - https://github.com/zeit/webpack-asset-relocator-loader/issues/36.
Will keep this issue open to track the overall Lighthouse support and integration test.
Looks like @nkzawa was able to get it to work with Now here: https://github.com/zeit/integrations/tree/master/lighthouse
Can't tell if it's using ncc
or not since I can't find the source code for @nkzawa/now-node-raw
.
@danoc Unfortunately, it's not ncc
. I couldn't make lighthouse
work with it.
btw I just made @nkzawa/now-node-raw
public https://github.com/nkzawa/now-node-raw
The remaining issue on Lighthouse seems to be the following code:
static requireGathererFromPath(path, options, coreAuditList, configDir) {
const coreGatherer = coreAuditList.find(a => a === `${path}.js`);
let requirePath = `../gather/gatherers/${path}`;
if (!coreGatherer) {
// Otherwise, attempt to find it elsewhere. This throws if not found.
requirePath = Config.resolveModule(path, configDir, 'gatherer');
}
const GathererClass = /** @type {GathererConstructor} */ (require(requirePath));
return {
instance: new GathererClass(),
implementation: GathererClass,
path,
options: options || {},
};
}
where the requirePath is effectively a dynamic wildcard value.
With https://github.com/zeit/webpack-asset-relocator-loader/pull/39 merged we will support wildcard requires, but the above support can only be completed when we have support for dynamic wildcard passing through the analysis.
I've created a tracking issue for this in https://github.com/zeit/webpack-asset-relocator-loader/issues/40.
The problem I'm attempting to run lighthouse with the
@now/node
builder, and I am running into a problem. Here is the src and logs of the lambda. I believe below is the simplest way to replicate the bug.The code
The command
ncc run test.js
The module resolution warnings
The error
spectrum reference