GithubHelp home page GithubHelp logo

ExecJS support about webpacker HOT 6 CLOSED

rails avatar rails commented on May 5, 2024
ExecJS support

from webpacker.

Comments (6)

dhh avatar dhh commented on May 5, 2024

No plans for that at the moment. But if you want to work on it, feel free to open a PR if you get something together!

from webpacker.

guilleiguaran avatar guilleiguaran commented on May 5, 2024

Sorry but probably no, per the FAQ of ExecJS: https://github.com/sstephenson/execjs#faq

Why can't I use CommonJS require() inside ExecJS?

ExecJS provides a lowest common denominator interface to any JavaScript runtime. Use ExecJS when it doesn't matter which JavaScript interpreter your code runs in. If you want to access the Node API, you should check another library like commonjs.rb designed to provide a consistent interface.

We need a full Node environment to run Webpack and ExecJS can't provide that.

from webpacker.

brodock avatar brodock commented on May 5, 2024

@guilleiguaran so could https://github.com/cowboyd/commonjs.rb theoretically provide the required support? I'm asking that because webpack's minimal node version is 0.5, so I'm guessing libv8 could provide whatever API's they are using.

While most of the time we would use nodejs, having an embedded executor could help into more restricted environments like heroku, or to build smaller docker images.

from webpacker.

guilleiguaran avatar guilleiguaran commented on May 5, 2024

@brodock Yes, I think should be possible to use commonjs.rb (if the version of v8 provided by therubyracer is good enough) to do it.

You can check https://github.com/cowboyd/less.rb that is based in commonjs.rb for reference.

from webpacker.

perezperret avatar perezperret commented on May 5, 2024

@brodock I've been lookig into this, I haven't been able to get this working, but I know webpack lets you expose libraries as globals, maybe these would work with ExecJS? I know react-rails takes advantage of global variables to do server-side rendering, and I have read of people getting it to work with browserify by exposing globals, so maybe you can create a pack that exposes some globals like this and load those into ExecJS? Please do let us know if you get this somewhere

from webpacker.

brodock avatar brodock commented on May 5, 2024

I will share a few experiments I've made. Because I don't understand well how the dependency system in JS works or is supposed to work, I think I'm missing something important:

https://gist.github.com/brodock/f8862a94e3494d2cc20689b4f8bd6dfa

from webpacker.

Related Issues (20)

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.