I think their point was that it is outside of their control. Protect themselves from someone downloading this and installing it into their dumb pipeline.
The common case of "bundling" is just concatenating files, which works fine if people add their damned semicolons.
To quote the author:
"not using any semicolons at all is a very popular trend in JS these days, so it is very possible this problem might happen in the real world"
This is the crux of the problem. Javascript programmers often follow trends, not sane practice. Looking at the code, for some reason there's a semi-colon before "require" invocations as well.
I don't even know what to say, at this point. Everyone is fired.
The common case of "bundling" is just concatenating files, which works fine if people add their damned semicolons.
To quote the author: "not using any semicolons at all is a very popular trend in JS these days, so it is very possible this problem might happen in the real world"
This is the crux of the problem. Javascript programmers often follow trends, not sane practice. Looking at the code, for some reason there's a semi-colon before "require" invocations as well.
I don't even know what to say, at this point. Everyone is fired.
> The common case of "bundling" is just concatenating files, which works fine if people add their damned semicolons.
bundling is not just concatenation, and certainly not in the "common" case.
> "not using any semicolons at all is a very popular trend in JS these days
> Javascript programmers often follow trends, not sane practice
Please have a look all the popular libraries and frameworks and their codebases[1], then tell me you still think your assessment of the Javascript community is at all fair.
> bundling is not just concatenation, and certainly not in the "common" case.
Fair enough, the common case is minification and concatenation. Or what else is it? The problem with the semicolon remains.
> Please have a look all the popular libraries and frameworks and their codebases[1], then tell me you still think your assessment of the Javascript community is at all fair.
In the real world, it's irrelevant what tools could be reasonably expected to do. What matters is what they actually do. Expecting your tools to insert semicolons for you is the path that leads to peril.
Great response from the dev, I wonder if this scales for popular projects though.
I've started to use Prettier on all projects. I don't even bother with things like these anymore. If the code is valid, it'll format my JS code uniformly, and if it's not I get a big red error telling me something up, precisely at line:x. I'm not sure if it would catch the edge-case this `;` at the beginning of the file is trying to solve though.
>In technical terms: Prettier parses your JavaScript into an AST (Abstract Syntax Tree) and pretty-prints the AST, completely ignoring any of the original formatting*. Say hello to completely consistent syntax!
12 comments
[ 4.2 ms ] story [ 51.8 ms ] threadThat is the wrong way to go about it. Please do not encourage this as a best practice.
Please use eslint, proper modules and a tried and tested bundler.
To quote the author: "not using any semicolons at all is a very popular trend in JS these days, so it is very possible this problem might happen in the real world"
This is the crux of the problem. Javascript programmers often follow trends, not sane practice. Looking at the code, for some reason there's a semi-colon before "require" invocations as well.
I don't even know what to say, at this point. Everyone is fired.
To quote the author: "not using any semicolons at all is a very popular trend in JS these days, so it is very possible this problem might happen in the real world"
This is the crux of the problem. Javascript programmers often follow trends, not sane practice. Looking at the code, for some reason there's a semi-colon before "require" invocations as well.
I don't even know what to say, at this point. Everyone is fired.
bundling is not just concatenation, and certainly not in the "common" case.
> "not using any semicolons at all is a very popular trend in JS these days
> Javascript programmers often follow trends, not sane practice
Please have a look all the popular libraries and frameworks and their codebases[1], then tell me you still think your assessment of the Javascript community is at all fair.
[1]https://www.javascripting.com/
Fair enough, the common case is minification and concatenation. Or what else is it? The problem with the semicolon remains.
> Please have a look all the popular libraries and frameworks and their codebases[1], then tell me you still think your assessment of the Javascript community is at all fair.
Yes, it is.
https://hackernoon.com/how-it-feels-to-learn-javascript-in-2...
If it is minification, then you already have a tool that process the code. The tool can easily just add the missing colon before concatenation.
Here's a very lengthy discussion on how the very popular minifier UglifyJS (version 1) originally removed trailing semicolons, causing this exact problem: https://web.archive.org/web/20130319222210/https://github.co...
In the real world, it's irrelevant what tools could be reasonably expected to do. What matters is what they actually do. Expecting your tools to insert semicolons for you is the path that leads to peril.
I've started to use Prettier on all projects. I don't even bother with things like these anymore. If the code is valid, it'll format my JS code uniformly, and if it's not I get a big red error telling me something up, precisely at line:x. I'm not sure if it would catch the edge-case this `;` at the beginning of the file is trying to solve though.
>In technical terms: Prettier parses your JavaScript into an AST (Abstract Syntax Tree) and pretty-prints the AST, completely ignoring any of the original formatting*. Say hello to completely consistent syntax!
It's like go fmt for Javascript.
https://github.com/prettier/prettier
If you're aren't using this you probably should to avoid bikeshedding in your team.