-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
π§ WIP: bundle analysis #61
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,12 @@ | |
|
||
let Bundle = require("./bundle"); | ||
let { abort, repr } = require("faucet-pipeline/lib/util"); | ||
let path = require("path"); | ||
|
||
module.exports = (config, assetManager, { watcher, browsers, compact } = {}) => { | ||
let bundles = config.map(bundleConfig => { | ||
// NB: bundle-specific configuration can override global options | ||
bundleConfig = Object.assign({ compact }, bundleConfig); | ||
return makeBundle(bundleConfig, assetManager.resolvePath, { browsers }); | ||
return makeBundle(bundleConfig, assetManager, { browsers }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not happy with the increasing amount of context we have to pass through in situations like this - not sure that can be avoided though. (In this case, we need |
||
}); | ||
|
||
let res = bundles.map(bundle => { | ||
|
@@ -38,13 +37,6 @@ module.exports = (config, assetManager, { watcher, browsers, compact } = {}) => | |
|
||
function makeWriter(bundle, assetManager, { fingerprint } = {}) { | ||
return ({ code, error }) => { | ||
if(code.length > 100000) { // ~100 kB -- XXX: arbitrary -- TODO: configurable | ||
console.error("β οΈ this bundle looks to be fairly big, you might " + | ||
"want to double-check whether that's intended and " + | ||
"consider performance implications for your users:\n " + | ||
path.relative(assetManager.referenceDir, bundle.target)); | ||
} | ||
|
||
let options = { error }; | ||
if(fingerprint !== undefined) { | ||
options.fingerprint = fingerprint; | ||
|
@@ -53,7 +45,7 @@ function makeWriter(bundle, assetManager, { fingerprint } = {}) { | |
}; | ||
} | ||
|
||
function makeBundle(config, resolvePath, { browsers }) { | ||
function makeBundle(config, { referenceDir, resolvePath }, { browsers }) { | ||
// dissect configuration for constructor | ||
config = Object.assign({}, config); | ||
let [entryPoint, target] = extract(config, "source", "target"); | ||
|
@@ -64,7 +56,8 @@ function makeBundle(config, resolvePath, { browsers }) { | |
|
||
entryPoint = resolvePath(entryPoint); | ||
target = resolvePath(target, { enforceRelative: true }); | ||
return new Bundle(entryPoint, target, config, { browsers, resolvePath }); | ||
return new Bundle(entryPoint, target, config, | ||
{ browsers, referenceDir, resolvePath }); | ||
} | ||
|
||
// removes properties from object, returning their respective values | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
// N/A | ||
// lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod | ||
// tempor incididunt ut labore et dolore magna aliqua | ||
// ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut | ||
// aliquip ex ea commodo consequat | ||
// duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore | ||
// eu fugiat nulla pariatur | ||
// excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia | ||
// deserunt mollit anim id est laborum | ||
// | ||
// lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod | ||
// tempor incididunt ut labore et dolore magna aliqua | ||
// ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut | ||
// aliquip ex ea commodo consequat | ||
// duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore | ||
// eu fugiat nulla pariatur | ||
// excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia | ||
// deserunt mollit anim id est laborum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider this a placeholder for now, until we've figured out detailed reporting (see above). It sort of duplicates
AssetManager#writeFile
's reporting.