antlr4ts icon indicating copy to clipboard operation
antlr4ts copied to clipboard

Can't resolve 'fs' when using antlr4-c3 package with code completion in angular 7

Open tsetsik opened this issue 5 years ago • 6 comments

My grammar file along with the generated lexer, parse and other files are located in the repository and I want to use the code completion feature of c3. But when implementing it I stumbled at the mentioned error

ERROR in ./node_modules/antlr4ts/misc/InterpreterDataReader.js
Module not found: Error: Can't resolve 'fs'

Since angular 6, there is no access to that module since it's client side, so what can be done in my case

tsetsik avatar Jul 16 '19 13:07 tsetsik

Good question, I don't think there should be a reference to module fs in the main code.

@sharwell, do I remember correctly that the Interpreter... stuff is really only needed for testing?

BurtHarris avatar Jul 18 '19 16:07 BurtHarris

Actually there is in here and the reference to the fs module is inside the InterpreterDataReader.js

tsetsik avatar Jul 25 '19 11:07 tsetsik

@BurtHarris the interpreter is also used by certain applications doing non-standard parsing

sharwell avatar Aug 31 '19 03:08 sharwell

@tsetsik I think the resolution here is to import specific classes rather than importing all of the runtime through index.ts.

sharwell avatar Aug 31 '19 03:08 sharwell

@tsetsik Worked for me

module.exports = {
    entry: './index.js',
    output: {
        path: './',
        filename: 'your.bundle.js'
    },
    node: {
        module: "empty",
        fs: "empty"
    }
};

LemonyPie avatar Dec 12 '19 13:12 LemonyPie

@tsetsik Worked for me

module.exports = {
    entry: './index.js',
    output: {
        path: './',
        filename: 'your.bundle.js'
    },
    node: {
        module: "empty",
        fs: "empty"
    }
};

There is no option to specify

node: {
   module: "empty",
   fs: "empty"
}

in webpack-5. What should i do now, i am kind of blocked by this. any suggestion would really helpful.

saravanan10393 avatar Jun 19 '20 07:06 saravanan10393