Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build script #36

Merged
merged 6 commits into from
Oct 18, 2017
Merged

Fix build script #36

merged 6 commits into from
Oct 18, 2017

Conversation

AquiGorka
Copy link
Contributor

@AquiGorka AquiGorka commented Oct 11, 2017

Ref: #34

This was tedious and in the end it worked, kind of, I'll explain more after I describe what is happening:

Apparently some dependencies (IPFS and tools/libraries that work with IPFS) do not export an es5 version of their code nor do they transpile from their es6 source in their build process.

There are several ways we could approach this. I thought the dependency list couldn't be so big so I decided to manually hack the source code directly transpiling and uglifying it. It seemed never ending - at some point during all this manual repeat process I thought I should've written a script to figure out the list but the thought of "one more and lets see if I get there" kept me going. Finally I added all the dependencies and the build script succeeded.

Sometimes after running this script ./scripts/hack-build.sh and running yarn build the build process may complain about not being able to minify a dependency. In my case the dependency was included in the list of files here but none the less the file was not transpiled nor uglified. Weird. In such cases running the process on such file directly and then executing the build command again worked.

To run the script on one file use the following: . ./scripts/hack-source.sh && hack_source PATH_TO_FILE (in the path to file don't add the node_modules directory. e.g ipld-git/src/util/tag.js)

So, the build command exited successfully. I deployed and then encountered this:

But I carried on, and then this happened when I tried to save a GIF:

image

I will continue working on this and update appropriately.

@chadoh
Copy link
Contributor

chadoh commented Oct 11, 2017

I think it would make sense to comment on multiformats/js-cid#38 and let them know that transpiling to ES5 fixes their issue, with no need to fix any duck typing or whatever else they go on about. I can let them know, if you want.

…f scripts

Add correct file execute permissions
@AquiGorka
Copy link
Contributor Author

Yeah. Awesome. Thanks.

@AquiGorka AquiGorka changed the title [WIP] Fix build script Fix build script Oct 16, 2017
@AquiGorka
Copy link
Contributor Author

AquiGorka commented Oct 16, 2017

Update 10/16/2017

Transpiling is not really necesary - It would be if we were targeting browsers that do not understand es6 syntax.

The Uncaught Error: second argument must be t a CID shows only if the build script includes a minify step. The app will not work if such step is included.

By removing the minify step altogether from the build process the app started working again. I tried adding uglify-es (Uglify version 3) (commented here as possible solution) as the minifier tool, but the error persists. We need to find a way to minify the code that does not break the app.

To remove the minify step I had to yarn eject which means we would no longer be using create-react-app. I am comfortable doing so, let me know how you feel about this @chadoh.

The other error, the one that reads in the lines of loading insecure content in https was fixed here: #39. This error did not stop the app for working correctly but there are problems with the IPFS network (discussed here) because the IPFS is working very slowly.

Copy link
Contributor

@chadoh chadoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AAAAAAAAHHHH 🙈 🙈 🙈

I've heard that ejecting a create-react-app app is ugly. Boy is it ever!

We're not doing much fanciness. All the fanciness that create-react-app and react-scripts were hiding from us was great to have, but without it, I suspect that creating our own webpack.config will save us time over the life of this project, even given that this project is only going to take another 4-6 weeks.

I guess the questions to answer are:

  • How long do you think it would take to make our own start and build scripts, using Webpack ourselves?
  • How much time do you think we'll waste, trying to comprehend wtf is happening with all of this?

@AquiGorka
Copy link
Contributor Author

AquiGorka commented Oct 18, 2017

How long do you think it would take to make our own start and build scripts, using Webpack ourselves?

Why do you want to make our own start & build scripts? The eject process left us with two scripts we can use for such purposes (and another one for testing when we integrate tests). Do you think it is overkill to use the ones left behind?
This is how the file structure looks like now:

.
├── README.cra.md
├── README.md
├── build
├── config
├── node_modules
├── package.json
├── public
├── scripts
├── src
└── yarn.lock
scripts
├── build.js
├── deploy.sh
├── start.js
└── test.js
config
├── env.js
├── jest
├── paths.js
├── polyfills.js
├── webpack.config.dev.js
├── webpack.config.prod.js
└── webpackDevServer.config.js

I think we can carry on with this new files, everything works as before. The difference is we now have the files out there instead of using a command that would simply hide all this from us.

How much time do you think we'll waste, trying to comprehend wtf is happening with all of this?

If we have to go down this path, I think we could take our app and implement nwb on top of it. I never had to, but I believe nwb supports custom configurations for webpack which we could use to remove the minify step and have our build script without all the files from eject.

Even if it were 2-3 days to make our own, I still think we can work with what was ejected and use those days to continue with tasks more relevant to Thicket.

Copy link
Contributor

@chadoh chadoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, you've convinced me.

@AquiGorka AquiGorka merged commit 83c16b8 into master Oct 18, 2017
@AquiGorka AquiGorka deleted the bug/fix-build-script branch October 18, 2017 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants