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 problem #960

Closed
wants to merge 3 commits into from
Closed

Fix problem #960

wants to merge 3 commits into from

Conversation

zyrong
Copy link
Contributor

@zyrong zyrong commented May 16, 2022

fix: css compilation problems when multiple entries

fix: Fix problems related to use rollup-plugin-terser

  1. The nameCache obtained in writebundle hook is not a reference to terseroptions
  2. JSON.stringify(nameCache) requires converting regex to a string first.

1. The nameCache obtained in writebundle hook is not a reference to terseroptions
2. JSON.stringify(nameCache) requires converting regex to a string first.
@changeset-bot
Copy link

changeset-bot bot commented May 16, 2022

🦋 Changeset detected

Latest commit: b0f2291

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

@rschristian
Copy link
Collaborator

rschristian commented May 16, 2022

Would you mind splitting half of this out into another PR? Fixing two (seemingly) different issues in one PR makes it a bit hard to review and follow.

Edit: Also helps the history. With both fixes in one PR, it's a bit murky which bit of code fixes what issue. If there's ever problems, it helps if it's clear to what issue a line was altered/added.

For both, do you mind writing up issues showcasing the problems you're experiencing?

css compilation problems when multiple entries

This is a bit vague, for example. It's difficult to review the work because I don't know what issues you've run into or if your added test cases adequately check your fix.

Thanks

@zyrong
Copy link
Contributor Author

zyrong commented May 16, 2022

Would you mind splitting half of this out into another PR? Fixing two (seemingly) different issues in one PR makes it a bit hard to review and follow.

Edit: Also helps the history. With both fixes in one PR, it's a bit murky which bit of code fixes what issue. If there's ever problems, it helps if it's clear to what issue a line was altered/added.

For both, do you mind writing up issues showcasing the problems you're experiencing?

css compilation problems when multiple entries

This is a bit vague, for example. It's difficult to review the work because I don't know what issues you've run into or if your added test cases adequately check your fix.

Thanks

What should I do to split into two pr

  1. This commit fixes that when different entries reference different CSS, only the related CSS of the first entry will be packaged. For specific changes, please see this commit. I also added the corresponding test case
    fix: css compilation problems when multiple entries

  2. This commit fixes the problems related to terser namecache. When terser compresses the code, the damaged variable names will be written to the namecache. Finally, the namecache will be written to the file system in this code, but after my test, it doesn't seem to work here
    fix: Fix problems related to use rollup-plugin-terser

@rschristian
Copy link
Collaborator

What should I do to split into two pr

CSS fixes in one, Terser thing in another. Specific commits get lost as PRs are squashed and merged.

Comment on lines -435 to +442
basic-css.css
basic-css.css.map
basic-css.esm.mjs
basic-css.esm.mjs.map
basic-css.js
basic-css.js.map
basic-css.umd.js
basic-css.umd.js.map
index.css
index.css.map
Copy link
Collaborator

Choose a reason for hiding this comment

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

This shouldn't be a patch if file names are changing without any user behavior alterations.

In spirit of keeping naming consistent, CSS output should also match every other file output by default, not fallback to index IMO.

Can we revert this bit, or switch this to a minor please?

Comment on lines -5 to +6
"regex": "^_"
"regex": "^_",
"reserved": []
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did these mangle files need to be updated in order to ensure tests still pass? If so, this too is a breaking change and the changeset should be corrected to mark this as a minor (Semver 0-major, breaking change = minor bump).

@@ -333,6 +328,7 @@ function getMain({ options, entry, format }) {
const shebang = {};

function createConfig(options, entry, format, writeMeta) {
const entryFileName = basename(entry, extname(entry));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is incorrect. Please use the existing naming setup that we had, it ensures names are properly stripped:

options.output.replace(EXTENSION, '.css'),

index.esm.js as an input needs to become index; yours would have it become index.esm, so index.esm.css would be output. We need to strip indicators towards ES module format, i.e., cjs, es[m], etc.

Comment on lines -505 to +478
options.output.replace(EXTENSION, '.css'),
resolve(outputDir, `${entryFileName}.css`),
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rather we not use outputDir as it isn't guaranteed to match up with expectations in the future (see #896)

CSS should continue to be output according to the result of getOutput for resilience IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about changing it to this

@zyrong
Copy link
Contributor Author

zyrong commented Jun 3, 2022

What should I do to split into two pr

CSS fixes in one, Terser thing in another. Specific commits get lost as PRs are squashed and merged.

I have split it into two independent PRs and modified them. Can you make some suggestions or reply to the changes

@rschristian
Copy link
Collaborator

Superseded by #961 & #966

@rschristian rschristian closed this Jun 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.

None yet

2 participants