OvermindDL1 / bucklescript-tea

TEA for Bucklescript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feature request: a skeleton project

martindemello opened this issue · 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.

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. :-)

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

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. :-)

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.

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.

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

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?

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

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.

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. :-)

File an issue please : )

File an issue please : )

Done. :-)

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

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

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

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 * :)

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? ^.^

Aha, thanks, I'll try that!

A TEA channel on Discord ReasonML would be nice

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. :-)

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

@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. :-)

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

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

@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?

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 Will component style alleviate the pain of nested Elm? It is dreadful! Wish to get something better in BuckleScript version.

@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. :-)

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

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

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. :-)

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

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 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 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.

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 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.

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

@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 Yes, gonna do that when I’m on my computer