question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Eleventy plugin not working

See original GitHub issue

Hello,

I’m trying to run this within 11ty but haven’t gotten past the setup part, as the plugin errors out with Could not get Shiki loaded async via 'deasync'

Minimal reproduction: https://replit.com/@dpfavand/11ty-shiki-twoslash-doesnt-work (click the green button to run).

It appears that the setupForFile promise is never resolved or rejected. But that’s about as far as I have been able to get.

Node 14 and 12
Eleventy 12.1
eleventy-plugin-shiki-twoslash 1.0.7

Has anyone else run into this lately? Running on Node 12 and 14, both promises and async should be available, so I’m not sure what’s going on.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
frencojobscommented, Jul 2, 2021

Update here. I don’t think it is possible. To override the default behavior of older markdown-it, we need to get access to the MarkdownIt() instance, which in our case is this.mdLib from the eleventy’s markdown engine, which I don’t think is possible to access through the config object, which is the only thing we have access to.

Long sentence short, even the official syntax highlighters use this weird syntax to highlight lines because it’s impossible to get attributes other than the first one.

	  ```js/1,3
	  console.dir(console);
	  ```
	  
	  👇 one plugin use this syntax
	  
	  ```js#13
	  console.dir(console);
	  ```
let highlights = new HighlightLinesGroup(split.join("/"), "/");

If that is the case, would you accept a documentation PR to make that clearer?

Yes, PRs are welcomed, and thanks.

1reaction
dpfavandcommented, Jul 1, 2021

Thanks for checking the example. I’ve been doing some more testing, and seem to have gotten past that error and run into another. So I don’t think it was hardware constraints - it’s even stranger.

My local machine is WSL Ubuntu with Node 14 and 15 (via nvm).

I’m using your example repo and mine.

Notes

First test: Node 12 vs 14 vs 15

Locally I tested 14 and 15, and used 12 in the replit. Node 15 worked, but 12 and 14 didn’t. This was disappointing because 14 is LTS and I was hoping this library would work on Node LTS. However, then I tested something else - the Eleventy build command.

npx @11ty/eleventy vs eleventy

I noticed that my initial build command followed the current Eleventy getting started guide: npx @11ty/eleventy. I set this as the build script in my package.json. On a whim I swapped it out for a more traditional eleventy command. And it worked! On both my local Node 14 and Replit’s Node 12. Mostly…

New error: Cannot read property 'split' of undefined

Although calling the build process through eleventy rather than npx @11ty/eleventy got past the async load error in my original issue, my repository runs into a different error, Cannot read property 'split' of undefined at https://github.com/shikijs/twoslash/blob/main/packages/remark-shiki-twoslash/src/index.ts#L35 - it appears that metaString is undefined at that point.

This occurs on my example in Node 12 and 14, but not in your example on Node 14. Your example also uses what I think is an old canary version of Eleventy. I tested changing your example to Eleventy 0.12.1 and it shows the same error, on both Node 14 and 15.

Conclusions

  • For whatever reason, npx @11ty/eleventy behaves differently than calling eleventy directly on Node 14. I don’t understand why, but basically on Node 12 and 14 you cannot build using npx @11ty/eleventy when you have this plugin configured. Not a huge deal in the end but definitely confusing.
  • The plugin does not (in my testing) appear to work with the current 12.1 release of Eleventy, with the undefined metaString issue. I will investigate further, perhaps the Eleventy plugin API changed since the canary version used in your example. If I find something I’ll post and/or try to make a PR.

The Replit example linked above is updated and exhibits the same behavior as my local Node 14 and 15 environments using Eleventy 12.1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plugins — Eleventy
Serverless : A plugin to run Eleventy in a serverless function for server side rendering (e.g. Previews in your CMS) and/or in very...
Read more >
@lit-labs/eleventy-plugin-lit - npm
Eleventy plugin for rendering Lit components.. Latest version: 0.2.3, last published: 4 ... Roadmap; Issues and comments; Contributing ...
Read more >
First Experience Building with Eleventy's WebC Plugin
My first attempt working with Eleventy's new Web Component plugin. ... down - running our web components during server build and not on...
Read more >
@11ty/eleventy-plugin-syntaxhighlight - npm package | Snyk
The npm package @11ty/eleventy-plugin-syntaxhighlight was scanned for known vulnerabilities and missing license, and no issues were found.
Read more >
The new Eleventy Vite Plugin—Eleventy Weekly №5 (2022 ...
Eleventy Dev Server: https://www.11ty.dev/docs/watch-serve/# eleventy -dev-server* Add a 404 Not Found Page to Eleventy ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found