Coder Social home page Coder Social logo

--define string parsing error about uglifyjs HOT 4 CLOSED

mishoo avatar mishoo commented on July 17, 2024
--define string parsing error

from uglifyjs.

Comments (4)

mishoo avatar mishoo commented on July 17, 2024

The defines are evaluated, so it complains that a is not defined. Evaluating arguments is probably not a good idea.

Any case, global defines should be constant. What would you actually expect from your sample, something like console.log(a,b)?

from uglifyjs.

mal avatar mal commented on July 17, 2024

Not quite, I was hoping for console.log("a,b");

I use this as I have a dictionary in a text file which is easier to maintain using line breaks, so in my cake build script I read it, convert the newlines to commas, and use DICTIONARY.split(',') in my main code. For now I've worked around it by changing my delimiter, however it'd still be good to solve this problem when defining strings.

from uglifyjs.

mishoo avatar mishoo commented on July 17, 2024

Ah, I see. That almost works:

echo 'console.log(TEST)' | uglifyjs2 -cd TEST='"a;b"'
→ console.log("a;b")

There's a bug currently if you include a comma, but it's just the command-line parser, nothing deep. I'll fix that.

Also note that you need to double the quotes (the first level is dropped by your shell).

from uglifyjs.

mal avatar mal commented on July 17, 2024

Yup, that's the work around I came to too! Thanks!

from uglifyjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.