This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-21
Channels
- # announcements (13)
- # babashka (63)
- # babashka-sci-dev (64)
- # beginners (37)
- # biff (1)
- # calva (10)
- # cider (7)
- # clj-kondo (15)
- # cljsrn (6)
- # clojure (26)
- # clojure-dev (10)
- # clojure-europe (34)
- # clojure-france (9)
- # clojure-nl (2)
- # clojure-norway (36)
- # clojure-uk (5)
- # clojurescript (142)
- # community-development (1)
- # conjure (3)
- # datalevin (5)
- # datalog (2)
- # datomic (5)
- # events (11)
- # fulcro (40)
- # gratitude (9)
- # guix (32)
- # honeysql (10)
- # jobs (2)
- # lsp (32)
- # malli (15)
- # meander (5)
- # membrane (43)
- # missionary (3)
- # nextjournal (9)
- # off-topic (38)
- # pathom (3)
- # polylith (30)
- # portal (78)
- # programming-beginners (4)
- # quil (6)
- # re-frame (20)
- # reagent (21)
- # remote-jobs (2)
- # shadow-cljs (7)
- # tools-deps (6)
- # xtdb (23)
Is there a better way to import and use an ESM only npm package like rehype-react than accessing the default
property:
(ns uniorg-test.core
(:require
["unified" :refer [unified]]
["uniorg-parse" :as uniorg-parse]
["uniorg-rehype" :as uniorg-rehype]
["uniorg-extract-keywords" :as extract-keywords]
["rehype-react" :as rehype-react]
["react" :refer [createElement]]))
(def processor (-> (unified)
(.use uniorg-parse)
(.use extract-keywords)
(.use uniorg-rehype)
(.use (.-default rehype-react) #js {:createElement createElement})))
(.then (.process processor "* hello org-mode") #(.log js/console %))))
@yosevuk see the translation examples here https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages
Ah, thanks! I take a look at that.
I bumped some JS dependencies, and I’m now seeing an error I haven’t seen before:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/me/project/node_modules/refractor/index.js from /Users/me/project/app.js not supported.
Instead change the require of index.js in /Users/me/project/app.js to a dynamic import() which is available in all CommonJS modules.
This was after bumping refractor from 3.3.1
to 4.2.2
. The app.js is built as target :node-library
. Is this a known issue with a known fix? I see they converted the refractor code to ESM between those versions, so it now requires import x from y
, but app.js
contains require("x")