javascriptangulartypescriptjison

How to include Jison into Angular?


How can one include the

Jison

javascript library into an angular project?

At the moment I'm getting:

WARNING in ./node_modules/jison/node_modules/source-map/lib/source-map/source-node.js 8:45-52 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

and

GET http://localhost:4200/vendor.bundle.js net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK) inline.bundle.js:55 Uncaught TypeError: Cannot read property 'call' of undefined at webpack_require (inline.bundle.js:55)


Solution

  • Install to your projects package.json

    npm install jison -s
    

    In your tsconfig.app.json include 'node' in your types array within compilerOptions

    "compilerOptions": {
        "types": [
           "node"
        ]
    }
    

    Then import it in any TypeScript file.

    import * as jison from 'jison';