Skip to content

v3.1.0 #150

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

v3.1.0 #150

wants to merge 10 commits into from

Conversation

moonglum
Copy link
Member

@moonglum moonglum commented Mar 9, 2025

Clean up utils

Looking into static, I noticed that we use the utils less than I thought.

  • FileManager is removed (pending based on the static/images work)
  • resolvePath is moved into util/index.js (this is a breaking change for aiur, but aiur will depend on 3 anyway)
  • generateFingerprint is moved into lib/manager.js as it is the only place where it is used (the test is moved accordingly)
  • SerializedRunner is moved to lib, as it is only used in core

This is a breaking change, but I could imagine putting it into core 3 as it is currently not used yet.

Remove remaining runtime dependencies

  • push the responsibility of dealing with browserslist to the plugin
  • make nite-owl optional. Open question: Should nite-owl be renamed to faucet-pipeline-watch?

Alternative name for static

To solve faucet-pipeline/faucet-pipeline-static#72 this allows users to use static as "assets".
Doc changes: faucet-pipeline/docs#105

Expose baseURI in manifest

This is needed in aiur, and removes some akward workarounds there.

Types

Add the types necessary to build a plugin. This does not run any TS on this project itself.

Remove --liveserve

The dependency has not been updated in over three years, and has severe security issues.

@moonglum moonglum changed the title Clean up utils v3.1.0 Mar 15, 2025
@@ -21,6 +21,10 @@ let DEFAULTS = {
bucket: "static",
plugin: "faucet-pipeline-static"
},
assets: {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file is also the place where we would mark the old name as deprecated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not currently sure how exactly we'd do that, especially because plugins can override these defaults? I guess we'll have to put on our hazmat suits and wade into the implementation eventually...

Copy link
Contributor

@FND FND left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me, though I've kinda run out of brainspace for the moment; let's conclude faucet-pipeline/faucet-pipeline-static#71 first.

}

// exported for testing
exports.generateFingerprint = generateFingerprint;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exports.generateFingerprint = generateFingerprint;
exports._generateFingerprint = generateFingerprint;

That makes it explicit; cf. _determinePlugins.


function generateFingerprint(filepath, data) {
let filename = path.basename(filepath);
let ext = filename.indexOf(".") === -1 ? "" : "." + filename.split(".").pop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not using path.extname here? (See potentially related discussion for faucet-static/static-images.)

(Though we might reasonably opt not to risk changing the implementation here, due to backwards-compatibility concerns.)

exports.generateFingerprint = generateFingerprint;

function generateHash(str) {
let hash = crypto.createHash("md5");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we perhaps change this to SHA-256? I realize that might be a backwards-compatibility concern though...

My results suggest that you should probably not be using MD5. MD5 is slower than SHA-256 and not as safe.

JavaScript hashing speed comparison: MD5 versus SHA-256

Comment on lines +3 to 4
let fs = require("fs");
let path = require("path");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well do this while we're at it:

Suggested change
let fs = require("fs");
let path = require("path");
let fs = require("node:fs");
let path = require("node:path");

let crypto = require("crypto");

exports.abort = abort;
exports.repr = repr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I had intentionally moved exports to the top (yay hoisting) so you don't have to go searching for them in the middle of random implementation details. 🤷

@@ -21,6 +21,10 @@ let DEFAULTS = {
bucket: "static",
plugin: "faucet-pipeline-static"
},
assets: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not currently sure how exactly we'd do that, especially because plugins can override these defaults? I guess we'll have to put on our hazmat suits and wade into the implementation eventually...

This moves the responsibility to the plugin, where it makes more sense.
This also removes the need for browserslist as a dependency in core.
@moonglum
Copy link
Member Author

Thanks for the feedback! I plan to incorporate that this week.

I worked on two things we discussed in a chat:

  1. I removed browserslist. The setup is really weird: We determine the browsers in core, and pass them to the plugin. But most of the handling is done by the plugin anyway. This doesn't make a lot of sense to me. I created this PR for faucet-pipeline-sass to show how I think it should work instead. This change in -sass, -css and -js would make it dual-compatible with 2.x and 3.x. See Implement browserslist handling outside of core faucet-pipeline-sass#210
  2. I made nite-owl optional. I would like to take that opportunity to rename it to faucet-pipeline-watch (or -watcher), as that is what nite-owl really is. That makes it more consistent with other additional libraries you need to install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants