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

Syntax Error in printable-characters.js #1

Closed
fresheneesz opened this issue Sep 21, 2017 · 12 comments
Closed

Syntax Error in printable-characters.js #1

fresheneesz opened this issue Sep 21, 2017 · 12 comments

Comments

@fresheneesz
Copy link

Line 12, zeroWidthCharacters, is not in key: value format. What is supposed to be there?

@fresheneesz
Copy link
Author

This problem exists in the latest version published on npm: 1.0.28. I'd recommend testing your modules before publishing.

@kroitor
Copy link
Collaborator

kroitor commented Sep 21, 2017

screenshot0081

@xpl
Copy link
Owner

xpl commented Sep 21, 2017

The module is tested before publishing (via a continuous integration service), and the deployment process is fully automated by that service. You can see the test/build log here: https://travis-ci.org/xpl/printable-characters

So a broken build can't get to NPM, really.

The error you experience is caused by an outdated version of JS engine you use, which does not understand a modern JS syntax. In ES2015 we can use the shorthand property notation:

var a = 'foo', 
    b = 42, 
    c = {};

// Shorthand property names (ES2015)
var o = {a, b, c};

See more here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer

@kroitor
Copy link
Collaborator

kroitor commented Sep 21, 2017

coverage081

Click it for details.

@xpl
Copy link
Owner

xpl commented Sep 21, 2017

If you still need the ECMAScript5 support (e.g. for older browsers), I'd suggest you to use Babel for transpiling your project: https://babeljs.io/

@xpl xpl closed this as completed Sep 21, 2017
@fresheneesz
Copy link
Author

@xpl Hmm, I see. I have an issue with UglifyJS v2.8.26 which is less than 6 months old. You might want to consider waiting to use modern JS syntax until popular tools like that catch up.

@xpl
Copy link
Owner

xpl commented Sep 21, 2017

@fresheneesz I expect people (who develop browser apps) to use Babel on their end, it's like an industry standard nowadays. Just add it before Uglify in your build script, and you can use all the modern syntax and forget about the compatibility problems.

But if you insist, I can pre-compile the library for you, putting the pre-built version right in the repository. It will just take some time to configure the CI build script properly...

@fresheneesz
Copy link
Author

@xpl I don't want to have you change your package if its only to support someone not using best practices that are easy to do. I was just surprised this came up suddenly when I've never had a js version compatibility issue before. I would imagine that updating to newer versions of JS should start at the application level first, and only be required by things applications depend on (eg modules) after a certain amount of adoption has happened. I don't know the state of adoption of these things at this point.

So ok, but I'm trying to add a babel step to my webpack 3 config and getting this issue: https://github.com/simlrh/babel-webpack-plugin/issues/1 . Maybe I'm just using an old version of node (5.1.0), but its not that old. Iono, I would imagine if I'm getting this issue, others will probably too. I don't wanna insist, but it seems like this could be a major pain for me and people with similar setups. Just updating on my dev machine isn't gonna cut it. Gotta update our production machine too.

@xpl
Copy link
Owner

xpl commented Sep 21, 2017

@fresheneesz The current (latest) version of Node is 8.5.0, and the 6.11.3 is the officially recommended stable build. I would personally recommend 7.6.0+, though, because of the native async/await syntax support, which really saves time for asynchronous code. Try to update and see if it helps... If the problem persists try reinstalling your node_modules folder (by deleting it and running npm cache clean --force) after the update.

@xpl
Copy link
Owner

xpl commented Sep 21, 2017

@fresheneesz Ah, and seems also that the babel-webpack-plugin you trying to use is not a very popular tool. Maybe it's just broken.

Have you considered using the babel-loader instead (2k stars on github)?

@xpl
Copy link
Owner

xpl commented Sep 21, 2017

@fresheneesz you can also try to switch from Uglify to a minifier that already supports ECMAScript6 syntax out of the box, like this one: babel-minify or uglify-es

@fresheneesz
Copy link
Author

@xpl Thanks for the suggestions. I got the babel-webpack-plugin to work on my local, but it eats up enough memory on the server to be killed by the out-of-memory-killer. : ( So does babel-minify-webpack-plugin. I feel like I've spent all day on this. Just to use your string.ify package..

Ok, I gave up on trying to add a babel step and instead wrote my own stringifier: https://github.com/fresheneesz/beautinator .

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

No branches or pull requests

3 participants