squint-cljs / cherry

Experimental ClojureScript to ES6 module compiler
https://squint-cljs.github.io/cherry
553 stars 22 forks source link

Play with robobun + cherry #82

Closed borkdude closed 1 year ago

borkdude commented 1 year ago

First time didn't work due to missing version

borkdude commented 1 year ago

@robobun

import { compileString } from 'cherry-cljs@0.0.0-alpha.60';
import { writeFileSync } from 'fs';

const code = compileString(`

(defn foo [^:js {:keys [x]}] x)

`);

writeFileSync('out.js', code);

const fooModule = await import('./out.js');

console.log(fooModule.foo({x: "Hello world!"}));
robobun commented 1 year ago

@borkdude here you go!

1 | import { compileString } from 'cherry-cljs@0.0.0-alpha.60';
3 |
                 ^
TypeError: compileString is not a function. (In 'compileString(`
      at /tmp/bun-JVPOeM/index.js:4:13
Code ```tsx import { compileString } from 'cherry-cljs@0.0.0-alpha.60'; import { writeFileSync } from 'fs'; const code = compileString(` (defn foo [^:js {:keys [x]}] x) `); writeFileSync('out.js', code); const fooModule = await import('./out.js'); console.log(fooModule.foo({x: "Hello world!"})); ```

Ran using the latest build of Bun, an all-in-one JavaScript runtime.

borkdude commented 1 year ago

@robobun

import { compileString } from 'cherry-cljs@0.0.0-alpha.60';
import { writeFileSync } from 'fs';

const code = compileString(`

(defn foo [^:js {:keys [x]}] x)

`);

writeFileSync('out.js', code);

const fooModule = await import('./out.js');

console.log(fooModule.foo({x: "Hello world!"}));
robobun commented 1 year ago

@borkdude here you go!

1 | import { compileString } from 'cherry-cljs@0.0.0-alpha.60';
2 | import { writeFileSync } from 'fs';
4 |
                 compileString(`
                 ^
TypeError: compileString is not a function. (In 'compileString(`
(defn foo [^:js {:keys [x]}] x)
`)', 'compileString' is undefined)
      at /tmp/bun-4Ssilw/index.js:4:13
Code ```tsx import { compileString } from 'cherry-cljs@0.0.0-alpha.60'; import { writeFileSync } from 'fs'; const code = compileString(` (defn foo [^:js {:keys [x]}] x) `); writeFileSync('out.js', code); const fooModule = await import('./out.js'); console.log(fooModule.foo({x: "Hello world!"})); ```

Ran using the latest build of Bun, an all-in-one JavaScript runtime.