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: Test suite now uses config files again #1623

Merged
merged 3 commits into from
Nov 26, 2021

Conversation

rschristian
Copy link
Member

@rschristian rschristian commented Nov 24, 2021

What kind of change does this PR introduce?

Test suite bug fixes & chores

Did you add tests for your changes?

Yes

Summary

Found in #1622, as it turns out, none of the config files (preact.config.js) have been loaded in our test suite in a fairly long time. The custom-webpack subject calls a method that doesn't exist anymore and yet the test isn't throwing. The config files aren't even being used.

This PR corrects that, though the implementation is a bit rough? Basically if esm cannot provide the config we simply require() it.

The behavior is a bit odd though and I don't quite understand what the issue is. export default function () {...} worked with our previous set up, but export default () => {...}, module.exports = function () {...}, and module.exports = () => {...} did not. With this fix, the two module.exports formats work in the suite again, but export default () => {...} does not. Not sure why this might be.

Does this PR introduce a breaking change?

No

@rschristian rschristian requested a review from a team as a code owner November 24, 2021 11:09
@changeset-bot
Copy link

changeset-bot bot commented Nov 24, 2021

⚠️ No Changeset found

Latest commit: b1ec138

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

packages/cli/tests/lib/output.js Outdated Show resolved Hide resolved
if (Object.keys(m).length === 0) {
try {
m = require(myConfig);
} catch {}
Copy link
Member

Choose a reason for hiding this comment

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

So this is just making sure that it's actually empty? (and we don't care about an error in that case)

Copy link
Member Author

Choose a reason for hiding this comment

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

That was the idea, yeah. By this point we've already ensured the file exists so if it's imported in some capacity and still empty, that's either a file with no exports or whatever this issue is with esm in our test suite. If a user does provide us with an empty config, that shouldn't be an issue.

The try ... catch I believe is unnecessary and I'll remove in a second. Left over fragment that I don't believe will do anything ever.

@rschristian rschristian marked this pull request as draft November 24, 2021 19:50
@rschristian rschristian marked this pull request as ready for review November 24, 2021 20:44
@ForsakenHarmony ForsakenHarmony merged commit 0509aa9 into master Nov 26, 2021
@ForsakenHarmony ForsakenHarmony deleted the fix/test-suite-config branch November 26, 2021 16:09
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