GithubHelp home page GithubHelp logo

pugjs / constantinople Goto Github PK

View Code? Open in Web Editor NEW
19.0 19.0 6.0 29 KB

Determine whether a JavaScript expression evaluates to a constant (using Acorn)

License: MIT License

JavaScript 18.78% TypeScript 81.22%

constantinople's People

Contributors

forbeslindesay avatar jeromew avatar timothygu avatar zackschuster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

constantinople's Issues

Is there some way to work with undefined?

Hello,
I need a way to work with undefined when parsing.
For example the expression
(foo.bar === underfined) ? 1: 2 not working.

Also
typeof foo['bar'] === ''undefined' - not constant
foo['bar'] === 'undefined - not constant
foo['bar'] == undefined - not constant

When I used the pug, I found out that the document was in discrepancy, whether I had a problem with it.

this is document

image

my test file a.js

const md = require("jstransformer")(require("jstransformer-markdown-it"));
const { resolve } = require("path");
const FS = require("fs");

console.log(md.render("# hello"));
console.log(md.renderFile("./a.md"));

const pug = require("pug");
const source = `
p some ss #[:md(inline='true') # hello]

include:md /a.md
`;
var html = pug.compile(source, {
  basedir: __dirname,
  filters: {
    md: (text, opts) => {
      console.log(opts);
      if (opts.inline) {
        return md.render(text).body;
      }
      if (opts.filename) {
        return md.renderFile(opts.filename).body;
      }
    }
  }
});

console.log(html());

image

it's work , i use string ‘true’ bypass constantinople logic 。 when i use #[:md(inline) # hello]

i got an error true is not constant. All filters are rendered compile-time so filter options must be constants

image

when i use include:md ./a.md or include:md a.md

image

i read the error source code , find the path need start with '/' so ,i add '/' bypass the logic。

did have something config let my code keep with document? 3q~ 🙏

server deployments require `core-js`

...entirely because of the babylon/babel-type dependencies. this adds a not-inconsiderable amount of needless runtime bloat that's quite painful to e.g. FTP deploy node_modules, even with mechanisms like .yarnclean to soften the blow.

you can see just how much the package bloated since the switch on packagephobia. it's quite the jump.

the original PR mentioned it was so people could "get the latest JS features", but that was almost 3 years ago & things have changed substantially since then.

as other parts of the pug tree already rely on acorn -- which is zero dependency & doesn't suffer from these issues as a result -- i would seriously recommend at the very least evaluating if returning to acorn is viable.

i would be willing to contribute work here.

*SyntaxError: Unexpected token (580:263) with new version of constantinople

Hi

We have started getting the following error in our application for last few days(approx 5 days)..

SyntaxError: Unexpected token (580:263)
at Parser.pp$4.raise (../../node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:2488:13)
at Parser.pp.unexpected ../../node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:623:8)
at Parser.pp.expect (../../node_modules/acorn/dist/acorn.js:617:26)
at Parser.pp$3.parseExprList (../../node_modules/acorn/dist/acorn.js:2406:14)
at Parser.pp$3.parseSubscripts ../../node_modules/acorn/dist/acorn.js:1900:29)
at Parser.pp$3.parseExprSubscripts (../../node_modules/acorn/dist/acorn.js:1875:21)
at Parser.pp$3.parseMaybeUnary ../../node_modules/acorn/dist/acorn.js:1849:17)
at Parser.pp$3.parseExprOp ../../node_modules/acorn/dist/acorn.js:1810:41)
at Parser.pp$3.parseExprOp (../../node_modules/acorn/dist/acorn.js:1812:19)
at Parser.pp$3.parseExprOp (../../node_modules/acorn/dist/acorn.js:1812:19)
at Parser.pp$3.parseExprOps (../../node_modules/acorn/dist/acorn.js:1793:15)
at Parser.pp$3.parseMaybeConditional (../../node_modules/acorn/dist/acorn.js:1774:19)
at Parser.pp$3.parseMaybeAssign (../../node_modules/acorn/dist/acorn.js:1750:19)
at Parser.pp$3.parseParenAndDistinguishExpression (../../node_modules/acorn/dist/acorn.js:2056:30)
at Parser.pp$3.parseExprAtom (../../node_modules/acorn/dist/acorn.js:1978:41)
at Parser.pp$3.parseExprSubscripts (../../node_modules/acorn/dist/acorn.js:1872:19)
at Parser.pp$3.parseMaybeUnary (../../node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:1849:17)
at Parser.pp$3.parseExprOp (/../../node_modules/acorn/dist/acorn.js:1810:41)
at Parser.pp$3.parseExprOp (../../node_modules/acorn/dist/acorn.js:1812:19)
at Parser.pp$3.parseExprOps (../../node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:1793:15)
at Parser.pp$3.parseMaybeConditional (../../node_modules/acorn/dist/acorn.js:1774:19)
at Parser.pp$3.parseMaybeAssign (../../node_modules/acorn/dist/acorn.js:1750:19)
at Parser.pp$3.parseMaybeAssign (../../node_modules/acorn/dist/acorn.js:1761:23)
at Parser.pp$3.parseExpression (../../node_modules/acorn/dist/acorn.js:1722:19)
at Parser.pp$1.parseStatement (../../node_modules/acorn/dist/acorn.js:777:45)
at Parser.pp$1.parseBlock (../../node_modules/acorn/dist/acorn.js:1040:23)
at Parser.pp$1.parseStatement (../../node_modules/acorn/dist/acorn.js:754:31)
at Parser.pp$1.parseIfStatement (../../node_modules/acorn-globals/node_modules/acorn/dist/acorn.js:879:26)

Getting this error with 3.1.2 version of constantinople. However if I replace with with an earlier version of the module, the error goes away.

Could you please suggest what could be the issue ..?

Thanks ..

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.