Skip to content
This repository has been archived by the owner on Sep 27, 2020. It is now read-only.

Publish an ES5 version of this package #25

Closed
thekevinbrown opened this issue Jun 13, 2018 · 1 comment
Closed

Publish an ES5 version of this package #25

thekevinbrown opened this issue Jun 13, 2018 · 1 comment

Comments

@thekevinbrown
Copy link
Contributor

Hi there!

I'm trying to use this module in a Create React App application. It works fine when I run it in development mode, but when I try to create a production build I get this:

$ react-scripts build
Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file: 

 	./node_modules/solidity-parser-antlr/src/index.js:2 

Read more here: http://bit.ly/2tRViJ9

There are 2 main approaches given on that bit.ly link to fix it.

Option 1: Publish an ES5 version of the module.

I tried to fix the problem myself with Rollup and Babel, but I'm getting a lot of problems with that approach that are deep in Antlr land, which is not my wheelhouse. This is where I'm up to:

https://github.com/CoinageCrypto/solidity-parser-antlr

It builds a dist/index.js file, but when I try to use that from the browser I keep getting "can't reference _____ of undefined" errors and similar.

So I shelved that approach and went off to the second fix:

Option 2: Include the module in my source code.

So I added this as a submodule. I then get this:

Failed to compile.

./src/lib/solidity-parser-antlr/antlr4/dfa/DFA.js
  Line 107:  'DFAStatesSet' is not defined  no-undef

Search for the keywords to learn more about each error.

Looking at that file, I don't actually see anywhere that DFAStatesSet is defined, and there are no other mentions of that anywhere in the project that I can find. Where should this be coming from?

I think this is actually an eslint error, which Create React App enforces quite strongly and I can't change the configuration without ejecting. So since it's working when it runs as a node module, I gave adding an // eslint-disable-next-line no-undef a try, but then just hit another file with the same situation.

I decided peppering what looks like a library's source code with eslint comments was probably a road to pain, I tried a more configuration-based approach. I looked if there's a way to disable eslint for that folder, but again, not without ejecting (discussed here: facebook/create-react-app#3886), which I could do, but seriously would like to avoid it.

Something Else I Tried

I've used GatsbyJS a lot in the past, so I threw this module at that build system and couldn't get it to run. I'm not sure why. I think again it's about it being ES6 packaged, but I figured it'd be best to start a discussion here before I go too deep into this.

Questions

So that brings me here:

  • If I continue, will you guys accept a PR that uses babel in some form to publish an ES5 version of this package to a dist folder?
  • Is the stuff in the antlr4 directory a library? Can we use an NPM dependency for that rather than packaging it with the source itself?
  • Has anyone been down this road before and has any interesting things to share?
@thekevinbrown
Copy link
Contributor Author

I think I found a really simple solution in #26, so I'm going to close this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant