-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Cannot read property 'Opal' of undefined #508
Comments
Hello @leanderhoedt could you please post the full stacktrace please ? I've had some issues with the latest version of Webpack, what version are you using ? |
Webpack: 4.10.1 console log:
webpack log:
|
Thanks I will try to reproduce this issue.
|
Well, this fixes my webpack warning. But I still get the error at runtime. |
I didn't get it to work with webpack 2 nor 3. |
Do you have a sample project that reproduce this issue ? I have a limited Internet access right now in the next days I will be able to work on it. |
I got it to work in a sandboxed application: https://github.com/leanderhoedt/SampleAsciiDocReact |
Ok thanks for taking the time to investigate this issue. |
I've created a simple project with Webpack 4.10+ and I can confirm that it's working: https://github.com/asciidoctor/asciidoctor.js/compare/master...Mogztter:integration-webpack?expand=1 @leanderhoedt Did you find the root cause ? |
@leanderhoedt ping 😉 |
hi, I'm also seeing this issue with the current react-react-app scripts (react-scripts import React from 'react';
import PropTypes from 'prop-types';
import Asciidoctor from 'asciidoctor.js';
import { translate } from 'react-i18next';
class AsciiDocTemplate extends React.Component {
state = { loaded: false, html: null };
componentDidMount() {
const { i18n, template, adoc, attributes } = this.props;
if (adoc) {
fetch(`${process.env.REACT_APP_STEELTHREAD_ASCIIDOC_PATH}/${i18n.language}/${adoc}`)
.then(res => res.text())
.then(html => {
const asciidoctor = Asciidoctor();
const asciihtml = asciidoctor.convert(html, { attributes });
!this.isUnmounted && this.setState({ loaded: true, html: asciihtml });
}); build errors/warnings:
|
Hi @priley86. I didn't find the Travis build: https://travis-ci.org/integr8ly/tutorial-web-app ? If I clone this repository, checkout the development branch and build the project (with Node.js 10) I should be able to reproduce this issue ? |
@Mogztter I can speak to this. I'll leave @priley86 to speak about the usage of the module and if it's affected by this warning. CI build is here btw https://circleci.com/gh/integr8ly/tutorial-web-app |
I see... the code for As you can see the code is generated by Opal. The Opal.def(self, '$node_require', TMP_Kernel_node_require_2 = function $$node_require(path) {
var self = this;
return $$($nesting, 'NODE_REQUIRE')(path.$to_str())
}, TMP_Kernel_node_require_2.$$arity = 1);
self.__fs__ = self.$node_require("fs");
self.__path__ = self.$node_require("path"); I will open an issue in the Opal repository to start the discussion about how we can improve it. |
I've solved the "Critical dependency" issue. Webpack will not generated this warning with the next version of Asciidoctor.js. I've created a simple "integration" to demonstrate how Webpack and Asciidoctor.js can work together: https://github.com/mogztter/asciidoctor.js-integration-webpack (currently I'm using Asciidoctor.js 1.5.7-rc.1 so the warning is still present but as soon as Asciidoctor.js 1.5.7 "final" is available I will update this project). |
As promised I've upgraded the project: https://github.com/mogztter/asciidoctor.js-integration-webpack @leanderhoedt @david-martin @priley86 Could you please confirm that this issue is gone (with Asciidoctor.js 1.5.7) ? |
This version (1.5.7) includes a fix for warnings during webpack builds See asciidoctor/asciidoctor.js#508
Thanks @Mogztter. |
Build is 💚 right ? So... 🎉 🎉 🎉 |
@Mogztter Yep. |
Closing this issue, feel free to reopen if the bug is still here. |
I use I get the following warnings when compiling:
The weirdest thing though is that when I run the app that does simple conversion of content to html, it runs fine the first time, and then it fails with the following:
Any idea for a workaround? I haven't yet dived deep into the asciidoctor packages to find a solution but it seems that something broke with the webpack integration. For reference this is the relevant webpack config:
If I put |
Hey @lambrospetrou I think it's related to https://github.com/Mogztter/asciidoctor-opal-node-runtime/issues/58
It means that Opal is loaded/required for each conversion which is probably not what you want. Opal cannot be loaded more than one in a runtime. Not sure why Webpack generates code that will effectively load Opal more than once. const Opal = require('asciidoctor-opal-runtime').Opal |
Yeah the double-call issue thing is caused only in development so it's probably something in the way webpack bundles the modules. In production I haven't seen this issue (yet). However the warnings are still there.
Does that mean that this should be fixed in a later version of |
👍🏻
You can safely ignore the warnings if you are not using a template converter. We are using
Yes, this fix is already on the v2.2.x branch: 33a6196 and I will probably cut a bug fix release in the next few weeks. |
I got an error:
I got a warning in webpack:
In my React application I used tried following:
Version used: 1.5.6
Someone encoutering the same problem?
The text was updated successfully, but these errors were encountered: