Skip to content
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

require("@bikeshaving/crank/html") fails #89

Closed
dfabulich opened this issue May 2, 2020 · 4 comments
Closed

require("@bikeshaving/crank/html") fails #89

dfabulich opened this issue May 2, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@dfabulich
Copy link

Use this repro script:

#!/bin/bash -ex

rm -rf wtfcjs
mkdir wtfcjs
cd wtfcjs
npm init -y
npm i @bikeshaving/crank
cat <<EOF > index.js
const {createElement} = require("@bikeshaving/crank");
const {renderer} = require("@bikeshaving/crank/html");

console.log(renderer.render(createElement("div", null, "Hello world")));
EOF
node index.js

Expected: You should see <div>Hello world</div> on the console
Actual:

/private/tmp/wtfcjs/node_modules/@bikeshaving/crank/html.js:1
export * from "./esm/html.js";
^^^^^^

SyntaxError: Unexpected token 'export'
    at Object.compileFunction (vm.js:344:18)
    at wrapSafe (internal/modules/cjs/loader.js:1106:15)
    at Module._compile (internal/modules/cjs/loader.js:1140:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
    at Module.load (internal/modules/cjs/loader.js:1040:32)
    at Function.Module._load (internal/modules/cjs/loader.js:929:14)
    at Module.require (internal/modules/cjs/loader.js:1080:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/private/tmp/tp/wtfcjs/index.js:2:20)
    at Module._compile (internal/modules/cjs/loader.js:1176:30)
@dfabulich
Copy link
Author

You can work around this issue by directly requiring the cjs version:

const {renderer} = require("@bikeshaving/crank/cjs/html");

@ryhinchey
Copy link
Contributor

The fact that you need to require the cjs bundle is outlined in the getting started docs https://crank.js.org/guides/getting-started.

Perhaps this should also be added the the renderers section as well

@dfabulich
Copy link
Author

Yes, but I filed this bug because my PR fixes it. 😎

@brainkim brainkim added the bug Something isn't working label May 4, 2020
@dfabulich dfabulich mentioned this issue May 17, 2020
@brainkim
Copy link
Member

brainkim commented Jul 2, 2020

Should be fixed in 0.2.0

@brainkim brainkim closed this as completed Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants