ggrossetie / opal-node-compiler Goto Github PK
View Code? Open in Web Editor NEWOpal Compiler for Node.js
Home Page: https://opalrb.com/
License: MIT License
Opal Compiler for Node.js
Home Page: https://opalrb.com/
License: MIT License
The Ruby version of Opal supports source maps:
require 'opal'
builder = Opal::Builder.new
builder.append_paths 'lib'
builder.build 'path/to/entrypoint'
code = builder.to_s
source_map = builder.source_map
opal-node-compiler does not expose source map and accessing it directly results in error:
const { Builder: OpalBuilder } = require('opal-compiler')
const builder = OpalBuilder.create()
builder.appendPaths('lib')
const code = builder.build(modulePath).toString()
const sourceMap = builder.$source_map()
SourceMap: uninitialized constant Opal::SourceMap
at Function.$$const_missing (node_modules/opal-runtime/src/opal.js:3052:52)
at const_missing (node_modules/opal-runtime/src/opal.js:224:32)
at Opal.const_get_qualified (node_modules/opal-runtime/src/opal.js:271:38)
at constructor.$$source_map (node_modules/opal-compiler/src/opal-builder.js:1988:20)
I'm trying to setup opal-compiler
in a NextJs + React App.
As soon as I put const Builder = require('opal-compiler').Builder
in the js where I want to use the buildString()
function, I get this error stacktrace:
process.stderr is undefined
$$6@webpack-internal:///./node_modules/opal-runtime/src/nodejs.js:676:5
$$write@webpack-internal:///./node_modules/opal-runtime/src/opal.js:18268:12
$$puts@webpack-internal:///./node_modules/opal-runtime/src/opal.js:18324:14
Opal.send2@webpack-internal:///./node_modules/opal-runtime/src/opal.js:1729:17
Opal.send@webpack-internal:///./node_modules/opal-runtime/src/opal.js:1719:17
$$warn@webpack-internal:///./node_modules/opal-runtime/src/opal.js:4799:16
warn@webpack-internal:///./node_modules/opal-runtime/src/opal.js:23182:10
handle_unsupported_feature@webpack-internal:///./node_modules/opal-runtime/src/opal.js:23169:11
$$freeze@webpack-internal:///./node_modules/opal-runtime/src/opal.js:23434:33
Opal.modules["opal/path_reader"]/</<@webpack-internal:///./node_modules/opal-compiler/src/opal-builder.js:971:198 Opal.modules["opal/path_reader"]/<@webpack-internal:///./node_modules/opal-compiler/src/opal-builder.js:1049:7 Opal.modules["opal/path_reader"]@webpack-internal:///./node_modules/opal-compiler/src/opal-builder.js:1050:5 Opal.load@webpack-internal:///./node_modules/opal-runtime/src/opal.js:2399:13
Opal.require@webpack-internal:///./node_modules/opal-runtime/src/opal.js:2427:17
Opal.modules["opal/builder"]@webpack-internal:///./node_modules/opal-compiler/src/opal-builder.js:1890:8 Opal.load@webpack-internal:///./node_modules/opal-runtime/src/opal.js:2399:13
Opal.require@webpack-internal:///./node_modules/opal-runtime/src/opal.js:2427:17
Opal.modules["opal-builder"]@webpack-internal:///./node_modules/opal-compiler/src/opal-builder.js:34439:8 Opal.load@webpack-internal:///./node_modules/opal-runtime/src/opal.js:2399:13
Opal.require@webpack-internal:///./node_modules/opal-runtime/src/opal.js:2427:17
@webpack-internal:///./node_modules/opal-compiler/src/index.js:6:6
./node_modules/opal-compiler/src/index.js@http://localhost:3000/_next/static/chunks/4.js:743:1 __webpack_require__@http://localhost:3000/_next/static/chunks/webpack.js?ts=1611842475447:873:31 fn@http://localhost:3000/_next/static/chunks/webpack.js?ts=1611842475447:151:20
@webpack-internal:///./Components/codenewton/common/IDE/Editors/common/Ruby/Opal.js:27:34
@webpack-internal:///./Components/codenewton/common/IDE/Editors/common/Ruby/Opal.js:161:30
./Components/codenewton/common/IDE/Editors/common/Ruby/Opal.js@http://localhost:3000/_next/static/chunks/4.js:119:1 __webpack_require__@http://localhost:3000/_next/static/chunks/webpack.js?ts=1611842475447:873:31 fn@http://localhost:3000/_next/static/chunks/webpack.js?ts=1611842475447:151:20
@webpack-internal:///./Components/codenewton/common/IDE/Editors/common/index.jsx:26:88
@webpack-internal:///./Components/codenewton/common/IDE/Editors/common/index.jsx:323:30
./Components/codenewton/common/IDE/Editors/common/index.jsx@http://localhost:3000/_next/static/chunks/4.js:131:1 __webpack_require__@http://localhost:3000/_next/static/chunks/webpack.js?ts=1611842475447:873:31 fn@http://localhost:3000/_next/static/chunks/webpack.js?ts=1611842475447:151:20
Now, I get the error is inside opal-runtime src/nodejs.js
, and says process.stderr
not being defined. The component where I'm using it being used server-side, i.e. it's SSR if the issue is process.stderr
not being available on the client side. Is there something I can look at to fix it for NextJs.
This stdlib
is required by Rouge.
See: https://github.com/mogztter/rouge.js
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.