opened
nescalante
username_0
when doing a `require('raml-1-parser')` with webpack, its throwing:

```
 ./node_modules/ts-structure-parser/dist/fsUtils.js
Module not found: Error: Can't resolve 'fs' in '/my-lib/node_modules/ts-structure-parser/dist'
 @ ./node_modules/ts-structure-parser/dist/fsUtils.js 4:9-22
 @ ./node_modules/ts-structure-parser/dist/tsStructureParser.js
 @ ./node_modules/ts-structure-parser/dist/index.js
 @ ./node_modules/raml-definition-system/dist/tsStruct2Def.js
 @ ./node_modules/raml-definition-system/dist/definitionSystem.js
 @ ./node_modules/raml-1-parser/dist/index.js
 @ myCode
```

thats because `fs` is not browser compatible, and only available via browserify transforms

you should either provide a valid version of this parser for the browser, or if not possible as a fallback provide the bundled js file included into the npm package so it can be used without having to clone the repo and run npm tasks
Cannot require with webpack
issue
created
nescalante
username_0
consider https://github.com/raml-org/raml-js-parser-2/pull/788
comment
created
sichvoge
username_1
I don't understand why that is a problem since the parser is used in MuleSoft's API designer which runs clearly inside the browser. 

So what's the problem exactly since it seems there is a version. Did you try the guide [here](https://github.com/raml-org/raml-js-parser-2#creating-standalone-browser-package)?

I also think that the browser version is always attached to the release. @username_2 can you advise, please!
comment
created
ddenisenko
username_2
Browser version for each release is attached as ZIP archive. Browser version is also available in NPM here: https://www.npmjs.com/package/raml-1-parser-browser

If you want to build the version manually, you can either run the script `generateBrowserVersion`, or, if you want to pack it as a part of your own package, add an alias for `fs` to your webpack config pointing to `web-tools/modules/emptyFS.js`
comment
closed
ddenisenko
username_2
issue
created
ddenisenko
username_2
Closing due to the timeout. Please reopen if still actual.
comment
created
nescalante
username_0
RAML Parser is still not working with webpack, reopen since webpack is a popular tool in the community and taking it out from RAML Parser is complicating it for developers adopting it.
comment
created
agustinlg
username_3
Agree that it would be an improvement if this works out of the box (or at least explicitly documented)

It did work on the designer but with Denis help, I thinks this was what we needed to add:

```
  resolve: {
    alias: {
      fs: path.resolve(projectRootPath, "./node_modules/raml-1-parser/web-tools/modules/emptyFS.js")
    }
  },
```
comment
created
nescalante
username_0
thats fine for me, would be good to have that documented in the readme
comment
created
ddenisenko
username_2
It is unclear for me how exactly you want it to work.

I see two different use-cases:

The first one is when you want need browser version to import the parser directly into html.
There are the following methods to do it:

1) RAML Parser packaged with webpack and having bower descriptor is attached to each parser release.

2) RAML Parser packaged with webpack is published as `raml-1-parser-browser` bower package.

3) RAML Parser packaged with webpack is published as NPM `raml-1-parser-browser` package.

4) There is a script to build browser version and an instruction of how to launch it in readme.

The second use case is when you want to package both your own code and the original code of RAML parser, then you need to create your own webpack configuration, which makes sense, I think. 

And in this case you need your own webpack configuration to take into account that browser version of RAML parser needs to have `fs` replaced with the stub, as was stated earlier in my answer:
```
If you want to build the version manually, you can either run the script generateBrowserVersion, or, 
if you want to pack it as a part of your own package, add an alias for fs to your webpack config pointing to web-tools/modules/emptyFS.js
```
Augustin posted the sample of such an addition.
I agree that this might be added to readme, but, please, take into account that you are the second user (if this is the option you need) that encounters this use case.

Also note that you can try to use any of the packages mentioned above (in example, npm browser package) to pack it with your own code, never tried that myself.

Please let me know what you think.
comment