Giter VIP home page Giter VIP logo

Comments (10)

sindresorhus avatar sindresorhus commented on May 28, 2024 7

Because Electron already supports the latest JavaScript features.

from electron-reloader.

kroko avatar kroko commented on May 28, 2024 4

For production code yes, also for this devtool?

Sure, you cannot avoid transpiling if you are using vanilla JS, but having some ECMA stage-x features that requires Babel for Node.js to be able to run the code, or even more if TS.
Personally in development phase

  • for main and preload side I switched to electromon, which is configured to consume compile products and reload on changes
  • main and preload compiled products are generated by webpack, auto recompiles on source changes (watch)
  • for renderer side I use webpack + wds + HMR + react-refresh (main (BrowserWindow) consumes http://... on dev and file:// on other tiers).

from electron-reloader.

swinc avatar swinc commented on May 28, 2024 2

Looking more into this, I'm not actually sure anymore why it wouldn't work when transpiled... I should have written some notes to myself about this. If it works fine for you, then great. I'll keep this open until I have time to look more into this and potentially remove that readme note.

Spent some time and it doesn't work when webpack'd because of the chokidar dependency, which contains file-system binary that doesn't make sense to pull into a webpack'd module (and doesn't work out of the box). Basically chokidar only makes sense when run directly by node because it's meant to watch the file system.

It works fine as far as I can tell when "transpiled" by TypeScript, although then you have to fiddle with webpack and TypeScript build tooling separately, and this increases the complexity of your whole build environment if you were relying on webpack and a TypeScript plugin loader before.

I can't think of a better fix than @feljx if you want everything to build through webpack. The module needs to be run directly by node and not packed into a webpack module.

from electron-reloader.

aidan-rypens avatar aidan-rypens commented on May 28, 2024 1

It works for me, so not a problem here. Thanks!

from electron-reloader.

kroko avatar kroko commented on May 28, 2024 1

@AidanRRR it makes sense to transpile. even if not using TS, one would use i.e. webpack to tree shake, use babel for ECMAScript stuff not available in Node (say do expressions), neatly bundle everything together.

from electron-reloader.

aidan-rypens avatar aidan-rypens commented on May 28, 2024

Ah. I think I didn't understand it correctly. So you meant like having something as Babel that writes out your Electron js files in order to support a lower ES?

But to have the Electron files written in Typescript to transpile; that is okay to do? It works with using the typescript built in transpiler.

Just making sure that I don't do something that I shouldn't! I'm sorry if I didn't get what you meant correctly.

from electron-reloader.

sindresorhus avatar sindresorhus commented on May 28, 2024

So you meant like having something as Babel that writes out your Electron js files in order to support a lower ES?

Yes.

But to have the Electron files written in Typescript to transpile; that is okay to do? It works with using the typescript built in transpiler.

That would be the same case.

from electron-reloader.

sindresorhus avatar sindresorhus commented on May 28, 2024

Looking more into this, I'm not actually sure anymore why it wouldn't work when transpiled... I should have written some notes to myself about this. If it works fine for you, then great. I'll keep this open until I have time to look more into this and potentially remove that readme note.

from electron-reloader.

aidan-rypens avatar aidan-rypens commented on May 28, 2024

@AidanRRR it makes sense to transpile. even if not using TS, one would use i.e. webpack to tree shake, use babel for ECMAScript stuff not available in Node (say do expressions), neatly bundle everything together.

For production code yes, also for this devtool?

from electron-reloader.

feljx avatar feljx commented on May 28, 2024

Looking more into this, I'm not actually sure anymore why it wouldn't work when transpiled... I should have written some notes to myself about this. If it works fine for you, then great. I'll keep this open until I have time to look more into this and potentially remove that readme note.

So I just ran into an issue where it is a problem. Custom webpack config with typescript and all the usual crazy module interop stuff that comes with it. Broke with a type error.
The workaround involves adding a tiny wrapper script in vanilla JS and requiring the transpiled app/module from within the wrapper.
#19

from electron-reloader.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.