Code Monkey home page Code Monkey logo

create-cljs-app's Introduction

Create CLJS App Build Status

Create ClojureScript apps with a single command.
It is focused on making it easy for JS and React developers to get started with ClojureScript.

Create CLJS App works on Windows, Linux, and macOS.
If something doesn’t work, please file an issue.

Heavily inspired on create-react-app. A lot of messages are mostly the same for now (create-react-app maintainers: if that's not ok, let me know).

Quick Overview

npx create-cljs-app my-app
cd my-app
npm start

Then open http://localhost:3000/ to see your app.
When you’re ready to deploy to production, create a minified bundle with npm run build.

Creating an App

You’ll need to have Node 10.16.0 or later version on your local development machine (but it’s not required on the server). You can use nvm (macOS/Linux) or nvm-windows to easily switch Node versions between different projects.

You'll also need a Java SDK (Version 8+, Hotspot).

To create a new app, you may choose one of the following methods:

npx

npx create-cljs-app my-app

(npx comes with npm 5.2+ and higher)

npm

npm init cljs-app my-app

npm init <initializer> is available in npm 6+

Yarn

yarn create cljs-app my-app

yarn create is available in Yarn 0.25+

It will create a directory called my-app inside the current folder.
Inside that directory, it will generate the initial project structure and install the transitive dependencies:

my-app
├── README.md
├── package.json
├── node_modules
├── shadow-cljs.edn
├── .gitignore
├── public
|  ├── css
|  |  └── style.css
|  ├── index.html
|  └── favicon.ico
└── src
   ├── app
   |  ├── cards.cljs
   |  ├── core.cljs
   |  ├── hello.cljs
   |  └── hello_cards.cljs       
   └── e2e
      └── core.cljs

Once the installation is done, you can open your project folder:

cd my-app

Inside the newly created project, you can run some built-in commands:

npm start or yarn start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser. The page will reload if you make edits.

The app uses Reagent, a minimalistic interface between ClojureScript and React.
You can use existing npm React components directly via a interop call.

Builds use Shadow CLJS for maximum compatibility with NPM libraries. You'll need a Java SDK (Version 8+, Hotspot) to use it.
You can import npm libraries using Shadow CLJS. See the user manual for more information.

npm run cards or yarn cards

Runs the interactive live development environment.
You can use it to design, test, and think about parts of your app in isolation.

This environment uses Devcards and React Testing Library.

npm run build or yarn build

Builds the app for production to the public folder.
It correctly bundles all code and optimizes the build for the best performance.

npm test or yarn test, and npm run e2e or yarn e2e

test launches the test runner in the interactive watch mode.
You can use test:once instead to run the tests a single time, and e2e to run end-to-end tests.

See the ClojureScript testing page for more information. E2E tests use Taiko to interact with a headless browser.

npm run lint or yarn lint, and npm run format or yarn format

lint checks the code for known bad code patterns using clj-kondo.

format will format your code in a consistent manner using zprint-clj.

npm run report or yarn report

Make a report of what files contribute to your app size.
Consider code-splitting or using smaller libraries to make your app load faster.

npm run server or yarn server

Starts a Shadow CLJS background server.
This will speed up starting time for other commands that use Shadow CLJS.

License

Create CLJS App is open source software licensed as MIT.

create-cljs-app's People

Contributors

0xflotus avatar dependabot-preview[bot] avatar dependabot[bot] avatar filipesilva avatar ieugen avatar juholei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

create-cljs-app's Issues

npm, npx, and yarn scripts are throwing an error — Cannot find module '../dist/lib'

Hey folks 👋

I'm having an error with npm, npx and yarn following the same instructions described on the README.

OS: Ubuntu 20.04.1 LTS
OpenJDK: build 11.0.8+10-post-Ubuntu-0ubuntu120.04


Using npm and npx.

~/dev❯ npm -v
6.14.4
~/dev❯ npm init cljs-app my-app

internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '../dist/lib'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/wcalderipe/.config/yarn/global/node_modules/create-cljs-app/bin/create-cljs-app.js:3:20)
                                                     /\ NOTICE THIS.

    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
~/dev❯ npx create-cljs-app my-app
Cannot find module '../dist/lib'

I also noticed that npm is trying to reach out yarn packages and I don't if this was intended.


Using yarn.

~/dev❯ yarn -v
1.22.5
~/dev❯ yarn create cljs-app my-app
yarn create v1.22.5
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

success Installed "[email protected]" with binaries:
      - create-cljs-app
[########################################] 40/40internal/modules/cjs/loader.js:638
    throw err;
    ^

Error: Cannot find module '../dist/lib'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/wcalderipe/.config/yarn/global/node_modules/create-cljs-app/bin/create-cljs-app.js:3:20)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
error Command failed.
Exit code: 1
Command: /home/wcalderipe/.local/npm/bin/create-cljs-app
Arguments: my-app
Directory: /home/wcalderipe/dev
Output:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

Note: I don't know if this might impact the template scripts but I have changed the npm prefix to a different folder under my user so I don't have to install global packages using sudo.

Don't commit node_modules/

By default this project creates an initial commit which includes node_modules/. It generally isn't recommended to commit node_modules/ to your repo especially now that package-lock.json/yarn.lock files for reproducible builds are common.

Bump shadow-cljs

Projects created via npx create-cljs-app and up using shadow-cljs version 2.10.22, which at this point is rather outdated. In addition it also fails to run with the latest cider-nrepl dependency since that seems to expect a newer nrepl version than the one shipped with 2.10.22.

2.18.0 is current and it might be useful to just run npm install shadow-cljs in the generated project to always get the latest. Rather than a fixed version.

Hint to run shadow-cljs pom to generate pom.xml

Hi!

Thanks for this great utility!

I'm using IntelliJ / Cursive and was struggling for a long while to find out why IntelliJ didn't resolve symbols.

You might want to add a reference in your documentation to:
https://shadow-cljs.github.io/docs/UsersGuide.html#_cursive

and maybe this specific part:
"Cursive does not currently support resolving dependencies via shadow-cljs.edn. You can run shadow-cljs pom to generate a pom.xml and import that using the IntelliJ."

to help others.

Regards,
Anders

How to make Devcards work?

I'm completely lost trying to get Devcards set up with this template. I can run the build watcher, but can't figure out where to go from there. Where do I access the page? I tried creating a cards.html as explained in the Devcards setup guide, but it's not working.

Creating new project fails: "file already exists"

Attempting to create a new project fails as it appears to try to create the new directory twice, and the second attempt fails and quits the creation process. Stack trace below:

Creating a new CLJS app in C:\projects\shadow-cljs-on-glitch.
fs.js:113
    throw err;
    ^

Error: EEXIST: file already exists, mkdir 'C:\projects\shadow-cljs-on-glitch'
    at Object.mkdirSync (fs.js:729:3)
    at C:\Users\jarca\scoop\persist\nodejs\cache\_npx\34216\node_modules\create-cljs-app\dist\lib.js:264:110
    at C:\Users\jarca\scoop\persist\nodejs\cache\_npx\34216\node_modules\create-cljs-app\dist\lib.js:139:301
    at C:\Users\jarca\scoop\persist\nodejs\cache\_npx\34216\node_modules\create-cljs-app\dist\lib.js:139:314
    at nd (C:\Users\jarca\scoop\persist\nodejs\cache\_npx\34216\node_modules\create-cljs-app\dist\lib.js:109:54)
    at md.f.J (C:\Users\jarca\scoop\persist\nodejs\cache\_npx\34216\node_modules\create-cljs-app\dist\lib.js:111:225)
    at rb (C:\Users\jarca\scoop\persist\nodejs\cache\_npx\34216\node_modules\create-cljs-app\dist\lib.js:38:219)
    at Q (C:\Users\jarca\scoop\persist\nodejs\cache\_npx\34216\node_modules\create-cljs-app\dist\lib.js:52:81)
    at id.f.V (C:\Users\jarca\scoop\persist\nodejs\cache\_npx\34216\node_modules\create-cljs-app\dist\lib.js:102:349)
    at Wa (C:\Users\jarca\scoop\persist\nodejs\cache\_npx\34216\node_modules\create-cljs-app\dist\lib.js:29:54)

Note on using cider

Newbie note:

The create-tauri-app command will ask what your dev command is (default is npm run dev).
Adding a command there will include it "beforeDevCommnad" in tauri.conf.json, like this:

    "beforeDevCommand": "npm run dev",

I had to remove this command to get it to work. Then I would just do npm run tauri dev, which waits for localhost:3000 to start up, at which point in emacs I would run cider with M-x cider-jack-in-cljs, then select shadow, and then the :app build, and then it works.

I think it would be useful to add a note somewhere in the readme for noobs like me.

Bump versions of shadow-cljs, reagent, etc in templates?

Would it be possible to bump the versions of things in template/package.json and template/shadow-cljs.edn to the latest? Or is there some procedure to easily bump them once create-cljs-app has been run?

Thanks, this package has been a great help!

Cannot create new project (Ubuntu 19.04)

When running the command npx create-cljs-app my-app, the following error is returned:

npx: installed 24 in 1.633s
Cannot find module '../dist/lib'
Require stack:
- /home/iwsfutcmd/.npm/_npx/32025/lib/node_modules/create-cljs-app/bin/create-cljs-app.js

Similar errors are returned when using npm init and yarn create.

Currently running this on Ubuntu 19.04, Node v12.8.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.