bucklescript-tea icon indicating copy to clipboard operation
bucklescript-tea copied to clipboard

feature request: a skeleton project

Open martindemello opened this issue 7 years ago • 40 comments

Could you add a repo with a small skeleton project, with the javascript pipeline (bundler, watcher etc.) configured and working? It would be a big help for people not coming from the javascript world.

martindemello avatar Jan 30 '17 00:01 martindemello

Could you add a repo with a small skeleton project, with the javascript pipeline (bundler, watcher etc.) configured and working? It would be a big help for people not coming from the javascript world.

Already planned and already done actually, I'm just waiting on a new release for the Bucklescript compiler to come out that fixes a bug in the bsb build system that I happened to expose. ^.^

It should be released this week he said though, when it is then expect not only an example skeleton project but also a blog post describing how this works. :-)

For note, I work with the Elixir language with the Phoenix library for my back-end web server usage. If you are as well then you can already see a how-to that I've made at http://blog.overminddl1.com/posts/setting-up-bucklescript-with-phoenix/ otherwise I'll be making a skeleton project that expects and uses nothing else (I'll probably use Brunch or rollup as the bundler as those are the two that I know best (I have... design issue that make me not like webpack and so forth), and a watcher is entirely useless as bucklescript has its own that is faster than anything else in any other system for bucklescript (as it keeps the build system loaded and ready). It will be a normal npm skeleton project though. :-)

I'll leave this open until Bucklescript's new release is out and I can get those made. :-)

OvermindDL1 avatar Jan 30 '17 15:01 OvermindDL1

awesome, thanks :) i'll give your elixir setup a try in the mean time, since i've been curious about phoenix too

martindemello avatar Feb 01 '17 21:02 martindemello

awesome, thanks :) i'll give your elixir setup a try in the mean time, since i've been curious about phoenix too

If you start anything with Phoenix or Elixir, definitely hop on to https://elixirforum.com/ for help and chat. :-)

OvermindDL1 avatar Feb 01 '17 21:02 OvermindDL1

I got your phoenix + bs setup up and running (thanks for the blog post!) and tried dropping the bucklescript-tea counter.ml into web/bucklescript and importing it into app.js. Compilation failed with

 [1/1] Building web/bucklescript/counter.cmj /home/mdemello/code/bs_test/lib/js/web/bucklescript/counter.js web/bucklescript/counter.cmi
FAILED: web/bucklescript/counter.cmj /home/mdemello/code/bs_test/lib/js/web/bucklescript/counter.js web/bucklescript/counter.cmi 
/home/mdemello/code/bs_test/node_modules/bs-platform/bin/bsc.exe -bs-package-name my_server  -bs-package-output commonjs:lib/js/web/bucklescript -bs-assume-no-mli -bs-no-builtin-ppx-ml -bs-no-implicit-include -bs-package-include bucklescript-tea -I web/bucklescript   -o web/bucklescript/counter.mlast -c  web/bucklescript/counter.mlast 
File "/home/mdemello/code/bs_test/web/bucklescript/counter.ml", line 1, characters 0-0:
Error: The files /home/mdemello/code/bs_test/node_modules/bucklescript-tea/lib/ocaml/tea.cmi
       and /home/mdemello/code/bs_test/node_modules/bs-platform/lib/ocaml/js.cmi
       make inconsistent assumptions over interface Js
ninja: build stopped: subcommand failed.

martindemello avatar Feb 02 '17 06:02 martindemello

Hmm, inconsistent assumptions, that might be a question for @bobzhang but first could you upload that as a demo project we can test? :-)

Also, try deleting the lib/ocaml and lib/bs directories, it might be holding on to an old file cache.

OvermindDL1 avatar Feb 02 '17 15:02 OvermindDL1

bsb -clean-world -make-world when you update a new compiler

bobzhang avatar Feb 02 '17 15:02 bobzhang

when you update a new compiler

Is there any way to version your cache files and if a version mismatch is detected then to kill and rebuild them?

OvermindDL1 avatar Feb 02 '17 15:02 OvermindDL1

I updated the blog page with that instruction for now at least. :-)

OvermindDL1 avatar Feb 02 '17 15:02 OvermindDL1

confirming that it worked for me. i might also have had a problem with installing bucklescript via npm -g; i deleted that and installed a project-local version.

martindemello avatar Feb 02 '17 22:02 martindemello

confirming that it worked for me. i might also have had a problem with installing bucklescript via npm -g; i deleted that and installed a project-local version.

It should work globally, but any change in its version may require doing that rebuild on all projects that use it (I like project-local installs personally).

@bobzhang So is there any chance of:

Is there any way to version your cache files and if a version mismatch is detected then to kill and rebuild them?

So all that would not be necessary. :-)

OvermindDL1 avatar Feb 02 '17 22:02 OvermindDL1

File an issue please : )

bobzhang avatar Feb 03 '17 01:02 bobzhang

File an issue please : )

Done. :-)

OvermindDL1 avatar Feb 03 '17 16:02 OvermindDL1

it would be nice to have a TodoMVC for a front end newbie : )

bobzhang avatar Feb 13 '17 18:02 bobzhang

it would be nice to have a TodoMVC for a front end newbie : )

Lol, true, and I already have the code too. ^.^

OvermindDL1 avatar Feb 14 '17 01:02 OvermindDL1

Newbie here as well :) Trying to get stuff working without bringing in a lot of tools. So, current setup:

bsconfig.json

{
    "name" : "hello",
    "sources" : { "dir" :  "src"},
    "bs-dependencies" : ["bucklescript-tea"]
}

package.json

{
    "name": "a",
    "version": "0.0.1",
    "dependencies": {
        "bs-platform": "1.5.1",
        "bucklescript-tea": "^0.2.6"
    },
    "scripts": {
        "build": "bsb",
        "watch": "bsb -w"
    }
}

Create counter.ml as per tutorial

> bsb
Error: Unbound module Tea
ninja: build stopped: subcommand failed.
Error happened when running command /Users/dmitriid/.nvm/versions/node/v6.9.1/lib/node_modules/bs-platform/bin/bsb.exe with args []

* tearing of hair ensues * :)

dmitriid avatar Mar 15 '17 13:03 dmitriid

There was an upgrade to this project last night to work with the latest bucklescript version (only if you have 1.5.2+ of Bucklescript), make sure you are updated and then be sure to compile dependencies via bsb -make-world as bsb will only compile your own project it seems? ^.^

OvermindDL1 avatar Mar 15 '17 14:03 OvermindDL1

Aha, thanks, I'll try that!

dmitriid avatar Mar 15 '17 14:03 dmitriid

A TEA channel on Discord ReasonML would be nice

geraldodev avatar Mar 23 '17 01:03 geraldodev

A TEA channel on Discord ReasonML would be nice

The Bucklescript channel is where it is done for now, but yeah they could start one if the normal channel gets full of that chat. ^.^

Regardless, you can ping my name on ReasonML to grab my attention. :-)

OvermindDL1 avatar Mar 23 '17 14:03 OvermindDL1

pinging this bug because it seems a shame not to release the skeleton project if it's mostly done anyway :)

martindemello avatar Apr 27 '17 20:04 martindemello

@martindemello Lol, yeah keep pinging me please, it keeps this fresh in my mind. :-)

I'd need to do minor updates to it to update it to the latest Bucklescript versions (which are still undergoing more changes! o.O) but it is pretty simple. @bobzhang on his repo has a bucklescript have tea or something like that project that shows it off simply too. :-)

OvermindDL1 avatar Apr 27 '17 21:04 OvermindDL1

hey @OvermindDL1, I would like to contribute to TEA, some tutorials to help people (like me) to get started is nice : )

bobzhang avatar Apr 28 '17 01:04 bobzhang

I've setup a small tea project a few days ago with latest BS. Can share it tomorrow if you want. Nothing special - just the counter example

neonsquare avatar Apr 28 '17 01:04 neonsquare

@bobzhang hi, have you read Elm's architecture tutorial? https://guide.elm-lang.org/architecture/ Do you think BuckleScript's TEA should keep the similar structure of chapters?

jackalcooper avatar Apr 28 '17 02:04 jackalcooper

hey @OvermindDL1, I would like to contribute to TEA, some tutorials to help people (like me) to get started is nice : )

Always awesome!

I do want to start working on the component model that I have in mind (webcomponent style), there's been a lot of people in the Elm community wanting it, so I hope I get time sometime soon, I'm in the midst of moving though. :-)

OvermindDL1 avatar Apr 28 '17 17:04 OvermindDL1

@OvermindDL1 Will component style alleviate the pain of nested Elm? It is dreadful! Wish to get something better in BuckleScript version.

jackalcooper avatar Apr 30 '17 08:04 jackalcooper

@OvermindDL1 Will component style alleviate the pain of nested Elm? It is dreadful! Wish to get something better in BuckleScript version.

That is entirely the point of it. :-)

Embedding a new tea app will be as simple as adding it to the view with a unique key and you pass information to it just like you pass them to, say, an input or a div or so, and you get information back via listening for on-whatever messages. This is the standard webcomponent methods nowadays. :-)

OvermindDL1 avatar Apr 30 '17 19:04 OvermindDL1

bucklescript templates look relevant to this - it would be awesome to have a bs-tea template: http://bloomberg.github.io/bucklescript/Manual.html#_using_existing_templates_since_1_7_4

martindemello avatar May 30 '17 06:05 martindemello

Maybe we can talk him into adding a --tea flag for bsb -init?

jackalcooper avatar Jun 13 '17 02:06 jackalcooper

Templates are perfect for this, but last I saw there were still deciding how to pull in user generated ones. It could soon just be something as simple as bsb -init https://github.com/OvermindDL1/bucklescript-tea-template-rollup.git or so I very much hope. :-)

OvermindDL1 avatar Jun 13 '17 15:06 OvermindDL1

Possibly relevant to this discussion: https://github.com/tcoopman/bucklescript-tea-starter-kit

canadaduane avatar Dec 11 '17 01:12 canadaduane

If the starter kit is not sufficient for anyone, feel free to create an issue or pull request to improve it.

tcoopman avatar Dec 11 '17 07:12 tcoopman

I just added a skeleton for brunch here. After brunch guys merge my entry into their skeleton list, it creates a new project with this skeleton with brunch new dir -s bs-tea

jackalcooper avatar Dec 12 '17 08:12 jackalcooper

@jackalcooper Ooo brunch support, do you call the bs compiler through brunch, does it work in watch mode or does brunch's watch just call the compiler on each invocation, and if so does it handle multiple files being changed within milliseconds of each other (that was a big issue I had a while back, brunch did not handle that well)?

OvermindDL1 avatar Dec 12 '17 15:12 OvermindDL1

@OvermindDL1 it is not done with brunch but NPM itself. The command ‘npm start’ starts both brunch and bsb in their watch modes. The auto reload works perfectly without noticeable lags. I’m been using this config for months and write thousands of lines of bs code.

jackalcooper avatar Dec 12 '17 15:12 jackalcooper

Ah, if stdin dies on the npm start command then will both brunch and bsb's watch's be stopped on all supported systems (as I recall Windows does not propogate the stdin being closed through npm start)?

OvermindDL1 avatar Dec 12 '17 15:12 OvermindDL1

@OvermindDL1 basically I have bsb watch ocaml source code and brunch watch js files. I know what you talking about because I suffered from this when using Elm. Unlike bsb Elm’s compiler doesn’t have watch more. So you have to have bundled tools watch none-js source code and js files at the same time which causes a lot of lag and redundant compilation problems.

jackalcooper avatar Dec 12 '17 15:12 jackalcooper

@OvermindDL1 it might not work on Windows sorry. I don’t have much experience on it.

jackalcooper avatar Dec 12 '17 15:12 jackalcooper

@OvermindDL1 it might not work on Windows sorry. I don’t have much experience on it.

Might just want to make a note of that in the docs then. I may dislike windows, but I do test on both linux and windows (I've yet to see how to run a mac OS in a VM so no clue how to test on it). :-)

OvermindDL1 avatar Dec 12 '17 15:12 OvermindDL1

@OvermindDL1 Yes, gonna do that when I’m on my computer

jackalcooper avatar Dec 12 '17 15:12 jackalcooper