Skip to content

fix: dynamically require os for edge runtime compatibility#1262

Merged
jakubpawlowicz merged 3 commits into
clean-css:masterfrom
shellscape:master
Nov 29, 2023
Merged

fix: dynamically require os for edge runtime compatibility#1262
jakubpawlowicz merged 3 commits into
clean-css:masterfrom
shellscape:master

Conversation

@shellscape

Copy link
Copy Markdown
Contributor

This essentially makes require('os') dynamic for edge worker runtime compatibility (shellscape/jsx-email#82 (comment)). The require of os as it currently is in master can be polyfilled away but requires use knowledge about bundlers and the correct way to bundle the package, if used directly, and any consumers of clean-css if used as a transitive dependency. Bundling is a minefield for most folks, and this should provide some relief.

Comment thread lib/options/format.js Outdated
var override = require('../utils/override');

function getSystemLineBreak() {
var systemLinkBreak = '\n';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should it be named systemLineBreak instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure should. I took the quick path and used github's editor to make the changes, and was counting on CI to catch any slips.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍 let's see if it catches anything

@jakubpawlowicz

Copy link
Copy Markdown
Collaborator

Thanks @shellscape - just one small nitpick. Let me know if I got it wrong!

@shellscape

Copy link
Copy Markdown
Contributor Author

alright a buncha stuff. I'll clean this up in a few

@shellscape

Copy link
Copy Markdown
Contributor Author

Very weird, however the vows test runner is running tests, it's doing so in an environment where globalThis.require is undefined. That's unexpected. (vows is also three years since its last update, probably a good idea to swap in a better test runner that doesn't have these kinds of side effects)

@jakubpawlowicz

Copy link
Copy Markdown
Collaborator

That's interesting. So in test env under Windows it falls back to '\n' which causes tests to fail, right?

@shellscape

Copy link
Copy Markdown
Contributor Author

Bingo. I'm looking into what vows is doing so I can get the correct check+polyfill for both tests and non-tests.

@shellscape

Copy link
Copy Markdown
Contributor Author

Gah. needs approval to run CI again.

@jakubpawlowicz

Copy link
Copy Markdown
Collaborator

It's odd that I have to approve it every time. Is there a setting to override it?

@shellscape

Copy link
Copy Markdown
Contributor Author

Actually not sure haha.

Before we merge, I'd like @cprussin to put eyes on this since they were first to report.

@cprussin

Copy link
Copy Markdown

oh awesome, thanks so much @shellscape . Yeah, as far as I know this will fix the edge runtime compat for this lib. Thanks again.

@jakubpawlowicz

Copy link
Copy Markdown
Collaborator

So we are fine to merge it, right?

@shellscape

Copy link
Copy Markdown
Contributor Author

I believe so!

@jakubpawlowicz jakubpawlowicz merged commit dee95d7 into clean-css:master Nov 29, 2023
@jakubpawlowicz

Copy link
Copy Markdown
Collaborator

Done. I'll do a patch release too.

@shellscape

Copy link
Copy Markdown
Contributor Author

Really appreciate the attention to this one 🙏

@jakubpawlowicz

Copy link
Copy Markdown
Collaborator

It's released in clean-css 5.3.3.

@shellscape

Copy link
Copy Markdown
Contributor Author

Amazing, thank you!

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.

3 participants