build system for espruino #679
Replies: 16 comments
-
Posted at 2017-01-08 by CriscoCrusader Looks like webpack works really well when using the optimization flag: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-08 by @joakim Have you had a look at Rollup? It claims to produce smaller bundles than Webpack and Browserify, and it has an uglify plugin. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-09 by @gfwilliams If you're trying to get the minimum possible size I'd look at some process that makes one single JS file from your many files - something that has tree-shaking so can remove unused code. The module implementation inside Espruino is quite efficient, assuming you just use it with However at the end of the day, all the names of exported functions have to stay the same - so some tool that knows enough about the whole project to rename all functions will be better. It just depends if you care about debugging or not. For production, it depends on the parts you're using and whether you expect their firmware to be up to date. For STM32-based Espruino boards I'd suggest getting a board as you want it, then using That way you update the Espruino firmware and your software all at once. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-09 by CriscoCrusader Seems the only way to run my code is minified, because there's no line breaks. The IDE runs each line separately, which breaks the script. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-10 by @gfwilliams How are you uploading? the command-line IDE should tweak any code formatting to make it work. Also if you use K&R-style formatting (with the opening bracket on the same line) everything will just work even if you upload the raw characters. edit: if you're using a command-line app, you need to use the proper |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-10 by CriscoCrusader Tonight I got as far as loading the build result on the board using the I copied the
I can see that it's invoking FWIW, calling |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-10 by @gfwilliams
Try |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-10 by CriscoCrusader Hi @gordon. Execution from the command-line works fine. I'm working with the espruino module as an import in my build script: https://github.com/stokebrain/morra-espruino1/blob/master/build.js The trouble starts with |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-10 by @gfwilliams I don't have time to help you out with that at the moment I'm afraid. I guess worst case you could just execute |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-10 by @joakim Why can't you use the Anyway, I'm actually making a Rollup plugin for Espruino. I hadn't thought of using Rollup for bundling Espruino projects before, but it makes perfect sense. It prefers ES modules ( https://github.com/joakimstai/rollup-plugin-espruino Note: I haven't actually tested it with an Espruino device yet, as I haven't got one on me :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-11 by CriscoCrusader This is tough, and frustrating. I can see that Why does this project need to use eval? @joakim, I am using the I want to enter the terminal after the code is loaded so I can receive the log output from the device as it's running. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-11 by @gfwilliams
It's because the Web IDE was originally made as a website where each file executed in the same scope, and adds itself to the global 'Espruino' variable - I can't just 'require()' everything as-is. Ideally I'd rewrite every file to handle both loading styles, but I don't have the time to do that while also checking it still works fine as a Chrome App, NWjs app, and on the Espruino website. As-is it does make debugging extremely frustrating, since the filenames aren't correct :( Looks to me like a) trying to write before you're actually connected There should really be a lot more being written to the console - it might be worth trying to figure out why that's not happening as the extra log messages would probably let you know what's going on. I still don't understand why you can't just use the existing espruino-cli code though - or at the very least start from that code which does exactly what you want and then strip out the bits you don't want. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-11 by CriscoCrusader
That's exactly what I did. The problem seems to be that it doesn't work after having already run |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-11 by @joakim @CriscoCrusader Ah, sorry! I only looked for |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-11 by @gfwilliams Actually it looks like your problem might be that sendFile ends up closing the connection when it's done: https://github.com/espruino/EspruinoTools/blob/gh-pages/index.js#L134 You might have to copy the code out of it and use it directly. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-12 by CriscoCrusader That worked :). I was thinking I would just reopen the connection after it closed. Thanks so much for your help :) https://github.com/stokebrain/morra-build/blob/master/main.js |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-01-08 by CriscoCrusader
For the project I'm doing, I'm writing each layer as reusable modules. The layers are:
I need to know how these should best be assembled. I've read the modules page but I still have questions.
Does the web IDE perform all the minification? Do I stand to gain any improvements/optimizations by using uglify-js2?
Is CommonJS the most efficient approach for Espruino builds using multiple custom modules? If you look at the output generated by a CommonJS system like Browserify, you'll see that a lot of junk has to be wrapped around each module to recreate the CommonJS system within a concatenated file.
When it comes time to sell Espruino Picos flashed with my code, how do I setup the production process?
Beta Was this translation helpful? Give feedback.
All reactions