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

Allow to build UMD files for packages having dependencies with top-level this in ESM files #340

Merged
merged 6 commits into from Nov 7, 2020

Conversation

Andarist
Copy link
Member

@Andarist Andarist commented Nov 6, 2020

Relates to #339

@changeset-bot
Copy link

changeset-bot bot commented Nov 6, 2020

🦋 Changeset detected

Latest commit: 7cdfd31

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

This PR includes changesets to release 1 package
Name Type
@preconstruct/cli 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

@codecov
Copy link

codecov bot commented Nov 6, 2020

Codecov Report

Merging #340 into master will increase coverage by 0.03%.
The diff coverage is 91.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #340      +/-   ##
==========================================
+ Coverage   84.85%   84.89%   +0.03%     
==========================================
  Files          33       33              
  Lines        1367     1377      +10     
  Branches      334      338       +4     
==========================================
+ Hits         1160     1169       +9     
- Misses        202      203       +1     
  Partials        5        5              
Impacted Files Coverage Δ
packages/cli/src/build/rollup.ts 86.36% <83.33%> (-0.53%) ⬇️
packages/cli/src/logger.ts 73.33% <100.00%> (+6.66%) ⬆️
packages/cli/test-utils/index.ts 97.77% <100.00%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d69fb74...7cdfd31. Read the comment docs.

case "EMPTY_BUNDLE":
case "EVAL":
case "CIRCULAR_DEPENDENCY":
case "THIS_IS_UNDEFINED":
Copy link
Member Author

Choose a reason for hiding this comment

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

as mentioned in that original issue - throwing for this in source files might still be a good idea, this would complicate thing though, currently, this config factory doesn't have access to the list of all monorepo packages so it cant quite distinguish if this has been reported by Rollup for a dependency of a monorepo package

Copy link
Member

Choose a reason for hiding this comment

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

We can make it so we only ignore it when type === 'umd' so the errors will happen for the CJS builds(which will always be built)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, I guess this would work. I was previously concerned about the same error not being reported for some build and reported for others which could confuse users, but when I think about this now - it makes sense and shouldn't really be confusing.

WDYT about making this actually only error for cjs if it's built at all times? This would avoid duplicating this error when you build both CJS and ESM

Copy link
Member Author

Choose a reason for hiding this comment

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

WDYT about making this actually only error for cjs if it's built at all times? This would avoid duplicating this error when you build both CJS and ESM

Ok, I see that this is not quite possible because "module" is just built together with "node-dev" type

@@ -60,7 +81,7 @@ export const rules = {
.join("\n"); //+
// "\n" +
// "".padEnd(node.tag.loc.start.column);
if (formatted !== str) {
if (!compareLines(str, formatted)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

this means now that the autofixer will reinsert whitespace again and this will potentially result in many meaningless diffs over time, so maybe lack of whitespace-only lines should be enforced rather than just allowed?

Copy link
Member

Choose a reason for hiding this comment

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

not sure I understand why this has been changed but I'm all for enforcing one kind of formatting

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 guess this is mainly an issue with my VScode setup that I might even need fixing at some point in time but not sure where this is coming from and I don't have time to tweak this.

Some setting in VSCode (or tools integrated with it) is removing trailing whitespaces for me - this is technically not correct for template literals so that setting has to be some general setting, not knowing about JS-specifics that would turn off this for some lines.

I would expect this kind of a thing to be quite a common setting though so even if I would manage to fix this on my end this might still be a good idea to unify to avoid similar problems for others.

@Andarist
Copy link
Member Author

Andarist commented Nov 6, 2020

@mitchellhamilton I think this is ready for review and merging now.

@emmatown emmatown merged commit a198073 into preconstruct:master Nov 7, 2020
@github-actions github-actions bot mentioned this pull request Nov 7, 2020
@Andarist Andarist deleted the fix/this-is-undefined branch November 7, 2020 09:13
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