asciidoctor / asciidoctor-reveal.js

:crystal_ball: A reveal.js converter for Asciidoctor and Asciidoctor.js. Write your slides in AsciiDoc!
http://asciidoctor.org
Other
289 stars 188 forks source link

TypeError: stubs.split is not a function #522

Closed signed closed 9 months ago

signed commented 10 months ago

I'm following the Node / JavaScript Setup (minimal reproducer). When I run node convert-slides.js I get this error (happens with npm, yarn, pnpm)

TypeError: stubs.split is not a function
    at Opal.add_stubs (.../minimal-asciidoctor-revealjs-reproducer/node_modules/.pnpm/@asciidoctor+opal-runtime@3.0.1/node_modules/@asciidoctor/opal-runtime/src/index.cjs:1516:19)
    at .../minimal-asciidoctor-revealjs-reproducer/node_modules/.pnpm/@asciidoctor+reveal.js@5.0.1_@asciidoctor+core@3.0.2/node_modules/@asciidoctor/reveal.js/dist/main.js:5261:8
    at initialize (.../minimal-asciidoctor-revealjs-reproducer/node_modules/.pnpm/@asciidoctor+reveal.js@5.0.1_@asciidoctor+core@3.0.2/node_modules/@asciidoctor/reveal.js/dist/main.js:5270:3)
    at resolveModule (.../minimal-asciidoctor-revealjs-reproducer/node_modules/.pnpm/@asciidoctor+reveal.js@5.0.1_@asciidoctor+core@3.0.2/node_modules/@asciidoctor/reveal.js/dist/main.js:5279:7)
    at Object.register (.../minimal-asciidoctor-revealjs-reproducer/node_modules/.pnpm/@asciidoctor+reveal.js@5.0.1_@asciidoctor+core@3.0.2/node_modules/@asciidoctor/reveal.js/dist/main.js:5302:12)
    at Object.<anonymous> (.../minimal-asciidoctor-revealjs-reproducer/convert-slides.js:4:21)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47

It looks like the problem is in Opal.add_stubs in @asciidoctor/opal-runtime.

  Opal.add_stubs = function(stubs) {
    var proto = Opal.BasicObject.$$prototype;
    var stub, existing_method;
    stubs = stubs.split(',');
    ...

The docs state that stubs should be an array. But split is not defined on array. From debugging it looks like some callers of Opal.add_stubs pass string[] e.g. ([$==,$require]) others pass a string of comma separated values (e.g. require,autoload).

ggrossetie commented 10 months ago

You only need @asciidoctor/core in your package.json:

https://github.com/signed/minimal-asciidoctor-revealjs-reproducer/blob/52e05834277807130744e30072446f88b5221593/package.json#L10-L12

The asciidoctor package is a meta-package that includes the CLI and @asciidoctor/core.

ggrossetie commented 10 months ago

I guess we need to release a new version to be compatible with the latest version of Asciidoctor.js. Both Asciidoctor reveal.js and Asciidoctor.js need to be compiled using the same version of Opal (which is not the case).

rawkode commented 9 months ago

@ggrossetie Is there a workaround for this atm?

ggrossetie commented 9 months ago

@rawkode you could use the previous version but I intend to release a new version which is compatible with Asciidoctor.js 3.x.

Pull request: https://github.com/asciidoctor/asciidoctor-reveal.js/pull/524

rawkode commented 9 months ago

@ggrossetie Awesome 👍🏻

Thanks for the assist, that PR helps.

ggrossetie commented 9 months ago

@signed @rawkode should be OK now, just tried https://docs.asciidoctor.org/reveal.js-converter/latest/setup/node-js-setup/ and it's working fine with 5.1.0.