Skip to content
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

fix: Corrects CSS output being overwritten when .cjs ext used #919

Merged
merged 2 commits into from Mar 3, 2022

Conversation

rschristian
Copy link
Collaborator

Fixes #883

@changeset-bot
Copy link

changeset-bot bot commented Dec 22, 2021

🦋 Changeset detected

Latest commit: 97c9a46

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
microbundle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@MinJieLiu
Copy link

When can this pr be merged

@@ -43,3 +43,5 @@ export function safeVariableName(name) {
const identifier = normalized.replace(INVALID_ES3_IDENT, '');
return camelCase(identifier);
}

export const EXTENSION = /(\.(umd|cjs|es|m))?\.([cm]?[tj]sx?)$/;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Names are hard... 😅

Certainly open to suggestions

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also (horrifyingly) supports the .cts and .mts extensions, as it looks like TS might head down that path

Comment on lines -485 to +487
options.output.replace(
/(\.(umd|cjs|es|m))?\.(mjs|[tj]sx?)$/,
'.css',
),
options.output.replace(EXTENSION, '.css'),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the only regex that actually needed to be corrected. #802 missed this when adding in support, which is totally understandable given that the regex existed in 3 separate locations. Hopefully extracting this out makes it easier to handle.

@ForsakenHarmony ForsakenHarmony merged commit 392d63e into master Mar 3, 2022
@ForsakenHarmony ForsakenHarmony deleted the fix/cjs-css branch March 3, 2022 17:04
@preact-bot preact-bot mentioned this pull request Mar 3, 2022
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.

.cjs extension in main package.json field causes imported CSS file output to be overwritten
3 participants