-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Make sure system exports are valid JavaScript #3960
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
Conversation
Also turn validate into a warning to be able to inspect generated output
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via
or load it into the REPL: |
Codecov Report
@@ Coverage Diff @@
## master #3960 +/- ##
==========================================
+ Coverage 97.19% 97.21% +0.01%
==========================================
Files 191 191
Lines 6703 6704 +1
Branches 1960 1960
==========================================
+ Hits 6515 6517 +2
Misses 99 99
+ Partials 89 88 -1
Continue to review full report at Codecov.
|
@lukastaegert I was hoping the code frame showing the error would be enough, but I appreciate it may be convenient to inspect the invalid code after a Is there a simple way to promote a warning to an error from the CLI while still retaining the output files? Perhaps this error could be deferred until after all the files have been emitted? A good compromise would be to change the option to allow:
|
I see that
But the rollup process returning a zero error code upon |
You want |
@lukastaegert Thanks for the quick reply. Unfortunately
Without
With
|
Wow... this is the weirdest thing. I had cut and pasted the option from #3960 (comment) and prepended the missing hyphen to get the error above. But when I manually retyped it - and it's seemingly identical - it does work:
There was a strange character in #3960 (comment) causing the problem:
That's nuts. Luckily, this unknown invisible character is not present when copy/pasted from the official docs in https://rollupjs.org/guide/en/#--failafterwarnings.
No rollup bug. |
Cursed unicode character 'EM DASH' (U+2014)!
I can't be the only one bit by this. |
One could pathologically use EM DASH as a short flag like In any case, this small patch could prevent such accidental CLI misuse of EM DASH and avoid hard to debug errors for others: --- a/cli/cli.ts
+++ b/cli/cli.ts
@@ -9,6 +9,11 @@ const command = argParser(process.argv.slice(2), {
configuration: { 'camel-case-expansion': false }
});
+if ("\u2014" /* EM DASH */ in command || "\u2E3A" /* TWO-EM DASH */ in command) {
+ console.error("Error: Hyphen-like character used instead of hyphen in command argument");
+ process.exit(1);
+}
+
if (command.help || (process.argv.length <= 2 && process.stdin.isTTY)) {
console.log(`\n${help.replace('__VERSION__', version)}\n`);
} else if (command.version) { without patch:
with patch:
Note: EM-DASH characters can still be used as arguments to other CLI options with the patch:
Edit: the patch was updated to put the check before |
Also turn validate into a warning to be able to inspect generated output
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
As prompted by #3952, this wraps certain System export related expressions in parentheses to avoid invalid code. Also, this changes the
validate
option from throwing an error to emitting a warning to allow inspecting the generated output manually.