GithubHelp home page GithubHelp logo

rrdelaney / reason-scripts Goto Github PK

View Code? Open in Web Editor NEW
630.0 13.0 58.0 2.14 MB

:beginner: Create a ReasonML and React development environment

License: MIT License

JavaScript 90.62% HTML 1.06% CSS 1.11% OCaml 0.59% Shell 6.63%
react reasonml bucklescript create-react-app

reason-scripts's Introduction


Reason Scripts

  $ yarn create react-app my-app --scripts-version reason-scripts

Reason Scripts provides a JS-like development environment for developing web apps with the Reason programming language and React. It bootstraps an environment to automatically compile all Reason code to JS, provide features like reloading and bundling, and seamlessly use JS code from Reason.

Build Status Build status

Getting Started

Using Yarn

Note that using yarn create requires Yarn 0.25 or later

To create a new app using Reason and React, run:

$ npm install -g bs-platform
$ yarn create react-app <app-name> --scripts-version reason-scripts
$ cd <app-name>
$ yarn start

Make sure to install bs-platform globally using npm instead of yarn.

Using npm

$ npm install -g bs-platform
$ npx create-react-app <app-name> --scripts-version reason-scripts
$ cd <app-name>
$ npm start

(npx comes with npm 5.2+ and higher, see instructions for older npm versions)

The policy of reason tooling is to support the current LTS release, so please make sure you have Node 8 or later.

Directory Layout

Creating a new app makes an <app-name> directory with the following layout:

<app-name>/
  README.md
  node_modules/
  package.json
  bsconfig.json
  .gitignore
  public/
    favicon.ico
    index.html
  src/
    index.re
    index.css
    app.re
    app.css
    logo.svg

Features

  • Highly-optimized build configuration
  • Pre-configured test runner
  • Friendly developer environment
  • "eject" Webpack config
  • Environment variable configuration
  • Automatic PWA configuration
  • Low configuration builds

Reason Entrypoint

The entry point to the app is src/index.re. From the start your new app will be based on Reason, but can seamlessly interop with existing JS files and projects!

Automatic Compilation of Reason/OCaml files

Any Reason/OCaml file will be automatically compiled to a JS file. For example, a file called math_fns.re can be required by a JS file:

import { add } from './math_fns.re'

const sum = add(1, 4)

Jest Integration

Reason Scripts will automatically configure a Jest environment to test Reason code. Any code found in a file ending with _test.re, _test.ml or test.js will be considered a test and run with Jest. From these files, the normal Jest API can be used interacting with any other modules defined in your app. For example:

/* math_fns.re */

let add = (x, y) => x + y;
/* math_fns_test.re */

open Jest;

test("addition", () => {
  let num_1 = 10;
  let num_2 = 12;

  expect(Math_fns.add num_1 num_2) |> toBe(22);
});

Or if you prefer writing your tests in JavaScript, just don't forget to import the tested module:

/* maths_fns.test.js */

import Math_fns from './math_fns.re'

test('addition', () => {
  const num1 = 10
  const num2 = 12

  expect(Math_fns.add(num1, num2)).toBe(22)
})

For more documentation on the Jest API, see bs-jest

Importing non-Reason files

You can require CSS files with:

[%bs.raw {|require('./App.css')|}];

or any other kind of file (like SVG's) with:

let logo : string = [%bs.raw {|require('./logo.svg')|}];

Help, Tips, and Tricks

My app won't compile on a fresh install

Try running npm install in your project directory. This helps refresh missing dependencies sometimes.

If this still does not work, make sure your file path does not include any spaces.

I got a SyntaxError after `yarn start` or `npm start` Try upgrading your Node to version 8 or later.

My editor isn't autocompleting

Editor support is provided by Merlin. To generate a .merlin file, run the app with npm start or yarn start.

See our full editor integration guide here: https://reasonml.github.io/docs/en/editor-plugins.html

I don't want reason-scripts to clear my terminal

Use FORCE_COLOR=true react-scripts start | cat - as your start command instead

Reason is awesome! Where can I learn more?

Checkout our fancy website: https://reasonml.github.io/!

We also have a very active Discord to come talk about Reason, and ask for help: https://discordapp.com/invite/reasonml

reason-scripts's People

Contributors

andriijas avatar anmonteiro avatar auchenberg avatar bebbi avatar bondz avatar bradfordlemley avatar enoahnetzach avatar existentialism avatar frontsideair avatar fson avatar gaearon avatar gaumala avatar iansu avatar jeffposnick avatar lpalmes avatar luftywiranda13 avatar mareksuscak avatar nhajidin avatar nikolas avatar pd4d10 avatar ro-savage avatar rrdelaney avatar ryansully avatar sidoshi avatar tharakawj avatar themre avatar timer avatar tuchk4 avatar viankakrisna avatar xjlim 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  avatar  avatar  avatar  avatar  avatar

reason-scripts's Issues

Some sort of configuration error?

After doing: create-react-app my-create-reason-react-app --scripts-version reason-scripts

> npm run start
Failed to compile.

./src/index.re
[3/4] Building src/ReasonReact.mlast
FAILED: src/ReasonReact.mlast
/usr/local/lib/node_modules/bs-platform/lib/bsc.exe -pp "/usr/local/lib/node_modules/bs-platform/lib/refmt3.exe --print binary"    -w -30-40+6+7+27+32..39+44+45+101 -nostdlib -I '/Users/justgage/code/my-create-reason-react-app/node_modules/bs-platform/lib/ocaml' -bs-no-version-header -no-alias-deps -color always -c -o src/ReasonReact.mlast -bs-syntax-only -bs-binary-ast -impl /Users/justgage/code/my-create-reason-react-app/node_modules/reason-react/src/ReasonReact.re
File "/Users/justgage/code/my-create-reason-react-app/node_modules/reason-react/src/ReasonReact.re", line 988, characters 48-50:
Error: 819: <UNKNOWN SYNTAX ERROR>
File "/Users/justgage/code/my-create-reason-react-app/node_modules/reason-react/src/ReasonReact.re", line 1:
Error: Error while running external preprocessor
Command line: /usr/local/lib/node_modules/bs-platform/lib/refmt3.exe --print binary '/Users/justgage/code/my-create-reason-react-app/node_modules/reason-react/src/ReasonReact.re' > /var/folders/qr/tdr3n25j6k32rjq1z17fy5pm0000gn/T/ocamlpp2f951e

ninja: error: rebuilding 'build.ninja': subcommand failed
Failure: /usr/local/lib/node_modules/bs-platform/lib/ninja.exe
 Location: /Users/justgage/code/my-create-reason-react-app/node_modules/reason-react/lib/bs

Sorry if this is something obvious ๐Ÿ˜…

missing part of the error message at terminal

Hi,

I created a project using reason scripts, and found the key part of the error message is missing on the terminal (yarn start), compared to the error displayed in the browser.

At the terminal:

  33 โ”†   | "" => ReasonReact.NoUpdate
  34 โ”†   | nonEmptyValue =>
  35 โ”†     state.todos
  36 โ”†     @ [
   . โ”† ...
  41 โ”†       },
  42 โ”†     ]
  43 โ”†   }
  44 โ”† | Edit(todo) => ReasonReact.NoUpdate

  This has type:
    list(TodoItem.todo)
  But somewhere wanted:
    at Array.map (<anonymous>)'a, action)

In browser:

  33 โ”†   | "" => ReasonReact.NoUpdate
  34 โ”†   | nonEmptyValue =>
  35 โ”†     state.todos
  36 โ”†     @ [
   . โ”† ...
  41 โ”†       },
  42 โ”†     ]
  43 โ”†   }
  44 โ”† | Edit(todo) => ReasonReact.NoUpdate
  
  This has type:
    list(TodoItem.todo)
  But somewhere wanted:
    ReasonReact.update(state, 'a, action)    at Array.map (<anonymous>)

so the key part of the message was ReasonReact.update(state, 'a, action) , which somehow missing in the terminal. Not quite sure reason-scripts formats and misses part of the error from the compiler.

Generate ES Modules rather than CommonJS

Like it says in the title. There's benefits to using ES Modules over CommonJS in conjunction with tools like Webpack, mainly to do with tree shaking. It'd be great if we could make ES Modules the default for reason-scripts.

Unexpected error. Please report it as a bug: ~ Creating in a mono Repo

Aborting installation.
Unexpected error. Please report it as a bug:
{ Error: Cannot find module '/Users/rayk/Projects/criticide/packages/app/node_modules/reason-scripts/package.json'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at checkNodeVersion (/Users/rayk/.config/yarn/global/node_modules/create-react-app/createReactApp.js:514:23)
    at getPackageName.then.then.then.packageName (/Users/rayk/.config/yarn/global/node_modules/create-react-app/createReactApp.js:312:7)
    at process._tickCallback (internal/process/next_tick.js:68:7) code: 'MODULE_NOT_FOUND' }

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting app / from /Users/rayk/Projects/criticide/packages
Done.
error Command failed.
Exit code: 1

I run the following in the packages directory of the mono-repo

yarn create react-app app --scripts-version reason-scripts@cra-next

the same problem occurs when using the current version, that is:

yarn create react-app app --scripts-version reason-scripts

current and cra-next works fine anywhere else.

Doesn't create Reason App anymore

I used this utility several times, but now it only generates a ReactJS app... I only have .js files with yarn create react-app my-app --scripts-version reason-scripts

node: v8.9.1
yarn: 1.1.0

Colorful error messages

Currently while stumbling upon error, messages are single color.

screen shot 2017-09-16 at 23 42 10

While building using bs-platform from CLI error messages are nicely colored.

screen shot 2017-09-16 at 23 42 20

I was trying to find where the problem is but I don't know which part of the stack is causing it (reason-scripts, bs-loader, react-dev-utils/WebpackDevServerUtils or maybe webpack).
I would really like to work on PR bringing colors to error messages ๐Ÿ™‚

Avoid npm link bs-platform if possible

Is it possible to avoid doing npm link bs-platform? When bs-platform is already globally installed using yarn global add bs-platform, npm link will overwrite the symlinks that used to point to the globally installed yarn version's binaries. This is probably not what the user wanted to happen. Ideally, bs-platform would would not care which package manager installed it and would not call a package manager directly.

This is something that bs-platform itself does, but we do it here as well in the prepare step. See rescript-lang/rescript-compiler#1972.

Build failed on linux

I tried to build an example app on both Mac and Linux, Mac works but Linux failed:

# Linux version
$ lsb_release -a
Distributor ID: Debian
Description:    Debian GNU/Linux 9.1 (stretch)
Release:        9.1
Codename:       stretch

Reproduce

yarn create react-app my-app -- --scripts-version reason-scripts

$ react-scripts build
Creating an optimized production build...
Failed to compile.

./src/index.re
File "/home/tienson/codes/ml/my-app/node_modules/reason-react/src/reasonReact.re", line 226, characters 34-47:
Error: 717: <SYNTAX ERROR>

Line 226:

let createClass (type reasonState retainedProps action) debugName :reactClass =>

Syntax error with fresh app

When creating a new app as described I get the following error:

Module build failed: /node_modules/bs-loader/index.js:84
      )
      ^

SyntaxError: Unexpected token )

Get SyntaxError from bs-loader

./src/index.re
Module build failed: /.../my-app/node_modules/bs-loader/index.js:84
      )
      ^
SyntaxError: Unexpected token )

The code was created from yarn create react-app my-app --scripts-version reason-scripts

Bsb error lines swallowed

Finally found a repro for this:

git clone https://github.com/tiensonqin/reason-error.git
cd reason-error
npm install
npm start

Doesn't happen when you run ./node_modules/.bin/bsb

Sync upstream changes

I tried to import my package.json so that I could access the version, however, I get the following error.

image

This was changed in create-react-app so that you can import the package.json, see here.

However, it seems that this is missing, see here.

I am assuming that this is because upstream changes have not been merged, and not because it was removed.

New Project Failed to Compile Error

Failed to compile

./src/index.re
File "/Users//Desktop/Code/giphy-app/node_modules/reason-react/src/ReactEventRe.re", line 52, characters 4-5:
Error: 2180:
File "/Users/
/Desktop/Code/giphy-app/node_modules/reason-react/src/ReactEventRe.re", line 1:
Error: Error while running external preprocessor
Command line: /usr/local/lib/node_modules/bs-platform/bin/refmt3.exe --print binary '/Users/*****/Desktop/Code/giphy-app/node_modules/reason-react/src/ReactEventRe.re' > /var/folders/t6/chlvzpdx0nb_98w5m29x90s80000gn/T/ocamlppe9088a

This error occurred during the build time and cannot be dismissed.

Compiler runs on an infinite loop when component is on subfolder

I've changed bsconfig.json sources so that I can have components in subfolders: "sources": [{"dir": "src", "subdirs": true}],

Doing that causes the compile to run again and again and never stopping:

compile-loop

It may not be obvious because of the framerate, but the compilation finishes, and starts again indefinitely.

Tests are broken

Partially Related to:
#50

version 0.9 (current)

In 0.9 there is an error when running the tests:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string

version beta3 (next)

  • Test files with format App_test.re are not matched by the provided glob **/?(*.)(spec|test).{js,jsx,mjs}.
    This glob matches App.test.js, but doesn't match neither App__test.bs.js nor <anything>.bs.js
    Fix for the glob #58

  • Tests don't work even if they are put in __tests__, because of SyntaxError: Unexpected token import

BS in-source files supports

Hey guys,

I've started getting to know reason and reason-react in the last days, so I'm still totally new to the syntax/language and the complementary tooling such as bucklescript.

I do have a side project that I'm working on from time to time which is basically a simple CRA application. So I decided to start putting some reason flavour in it and as far as I could understand it it should be easy to migrate little pieces to reason incrementally.

Long story short:

  • I've replaced react-scripts with reason-scripts
  • I've migrated index.js to index.re
  • I've activated the new in-source builds in conjunction with .bs.js suffix (as recommended from the docs)
  • ...and I bumped into some small issues ๐Ÿ™ƒ

One thing, being that there was a bug in bs-loader that would ignore the suffix. I've opened a PR for that rrdelaney/bs-loader#40
However, reason-scripts still uses version 1.8.0 of bs-loader and it should be upgraded to version 2. Not a huge deal, as this issue can be worked around using a resolutions field with yarn.
Still, I think reason-scripts should support this new options out of the box.

Here comes the additional missing feature: if I activate the in-source option, I'll end up having the compiled file .bs.js next to the source file

Foo.bs.js
Foo.re

However, the eslint rule used by webpack should exclude those auto generated files ending with .bs.js. Using a .eslintignore won't help because it's disabled on purpose on the rule.

A naive "fix" would be something like this:

- test: /\.(js|jsx|mjs)$/,
+ test: function testForJsFilesExcludingBsFiles(fileName) {
+   if (fileName.endsWith('.bs.js')) return false;
+   return /\.(js|jsx|mjs)$/.test(fileName);
+ },

So far those have been the "issues" that I have encountered while getting started with reason.

It would be nice to have them addressed, I'm not sure if there are other things that need to be improved though. But in general, having a good reason/bs support out of the box would be very nice.

Thanks a lot! ๐Ÿ™

PS: I wanted to open an issue first to discuss those things, I'm also happy to provide a PR if you guys want to ๐Ÿ˜‰

Failed to compile under WSL created with ocaml-reason-wsl

Errors out with:

./src/index.re
script: cannot set signal handler: Function not implemented

After setting it up according to guide.

Steps to reproduce:
Install WSL
In windows run: npm i -g ocaml-reason-wsl
In WSL:
npm install -g create-react-app
create-react-app reason-test-scripts --scripts-version reason-scripts
cd reason-test-scripts
npm start

Need to run `npm install` after create-react-app has run when using npm

When trying to do what the README says using npm:

$ npm install -g bs-platform
$ npx create-react-app <app-name> --scripts-version reason-scripts
$ cd <app-name>
$ npm start

I got the following error:

Failed to compile
./node_modules/reason-react/src/ReactDOMRe.js
Module not found: Can't resolve 'bs-platform/lib/es6/caml_builtin_exceptions.js' in '/home/frederik/projects/reason-test/node_modules/reason-react/src'
This error occurred during the build time and cannot be dismissed.

This seems to be due to the fact that create-react-app does not install all required dependencies as the following will work as expected:

$ npm install -g bs-platform
$ npx create-react-app <app-name> --scripts-version reason-scripts
$ cd <app-name>
$ npm install
$ npm start

Is this a bug in the project setup or is it expected to be done like this and the missing npm install needs to be added to the README?

For the record this is my setup:

โžœ  reason-test npm -v
6.1.0
โžœ  reason-test node -v
v8.11.3
โžœ  reason-test npm list -g bs-platform
/home/frederik/.npm-global/lib
โ””โ”€โ”€ [email protected] 

Handle unit tests in JavaScript

Because bs-jest is still WIP and experimental, it can be very convenient to write unit tests in JavaScript. But currently it's not possible without ejecting because it's impossible to modify the testMatch parameter of Jest config (in package.json), or react-scripts complains when launching tests.

I think it would be great if default testMatch parameter of Jest config included both *test.re* and *test.js to allow writing tests in JavaScript.

Test Not Running Immediate After create-app

PROBLEM
Running yarn test immediate aftering creating a new ReactReason app, generates the following errors.

Case 1

Install with the following

yarn create react-app my-app --scripts-version reason-scripts

results in:

yarn run v1.7.0
$ react-scripts test --env=jsdom --verbose
2018-07-02 16:02 node[7962] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2018-07-02 16:03 node[7962] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2018-07-02 16:03 node[7962] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: EMFILE: too many open files, watch
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:120:28)
Emitted 'error' event at:
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:126:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Case 2

All tried to recreate using next version:

yarn create react-app my-next-app --scripts-version reason-scripts@next

results in:

018-07-02 16:14 node[10727] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
2018-07-02 16:14 node[10727] (FSEvents.framework) FSEventStreamStart: register_with_server: ERROR: f2d_register_rpc() => (null) (-22)
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: EMFILE: too many open files, watch
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:120:28)
Emitted 'error' event at:
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:126:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

There appears to be no other problems, build is working, dev server is good.
I do suspect this issue is related to an upstream issue in create-react-app. Installing watchman does appear to fix the problem on new installs, yet this is not a universal solution, I managed to recreate the above in a project that had a number (25) test files.

Hope the report helps.

ENV

  • Node v10.5.0
  • Yarn 1.7.0
  • MacOSx 10.13.5
  • Bsb 3.1.5 (Installed Globally with npm)

Fresh install build failed

Hi,

After creating a new project, I've got this result :
capture d ecran 2018-03-24 a 23 55 38

Even after doing another npm i it still the same.
Any ideas ?

Thanks ๐Ÿ˜„

Doesn't work the first time

Hi, I follow all these steps

$ npm install -g bs-platform
$ yarn create react-app <app-name> --scripts-version reason-scripts
$ cd <app-name>
$ yarn start

But when I open the browser I see only a blank page, and when I open the .re files I see errors like
The module or file ReasonReact can't be found. Unbound module ReactDOMRe Unbound module Jest

when ran yarn start I saw the message Compiled successfully

I have bs-platform installed using `yarn global add` and a newly created app doesn't recognize it

After I installed bs-platfrom using yarn global add bs-platfrom I launched the app using yarn start it shows me this error

./src/index.re
Package not found: resolving package bs-platform in /  
File "bsconfig.json", line 1
Error: package bs-platform is not found  , it is the basic package required, if you have it installed globally
Please run 'npm link bs-platform' to make it available

I made sure that bsb, bsc and bsrefmt are accessible through command line and they were
had to install bs-platfrom again through npm and then npm link bs-platform to make it work

Module not found

Hi !
I've made:

create-react-app <app-name> --scripts-version reason-scripts

and recieve error: Module not found: Can't resolve '.app' in 'C:\projects\rr\src'

Furthermore a few minutes ago I've updated bs-platform, maybe this related?

suggestion: add `npm install` in readme "Getting Started" steps

I followed the npm steps in the readme:

$ npm install -g bs-platform
$ npx create-react-app <app-name> --scripts-version reason-scripts
$ cd <app-name>
$ npm start

but I was shown a blank page. It took me a few minutes to realize I need to npm install all of the dependencies (i.e. node_modules) in the project first.

Perhaps the steps should read as follows?

$ npm install -g bs-platform
$ npx create-react-app <app-name> --scripts-version reason-scripts
$ cd <app-name>
$ npm install
$ npm start

Fails to build after creating

Immediatly after creating the app, I try to build/start and I get the following error:

pablo@ironman test-reason-react $ yarn build
yarn run v1.9.4
$ react-scripts build
Creating an optimized production build...
Failed to compile.

./src/index.re
Module build failed: /Users/pablo/Documents/work/projects/personal/test-reason-react/node_modules/bs-loader/index.js:84
      )
      ^

SyntaxError: Unexpected token )


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Cannot start or build reason app inside node:9-alpine container

yarn start and yarn build both fail inside a docker container built using the instructions in the docs. Running inside alpine is a must for compiling inside a CI pipeline.

To reproduce:

  1. Build image using this Dockerfile. e.g.: docker build . -t sad-reson
FROM node:9-alpine

RUN apk update && apk upgrade && \
  apk add build-base bzip2 git tar curl ca-certificates python

RUN addgroup -S app && adduser -S -G app app 

USER app

RUN mkdir ~/.npm-global
RUN npm config set prefix '~/.npm-global'
ENV PATH=~/.npm-global/bin:$PATH
# RUN npm install -g [email protected] # fails the same, with or withouth this line
RUN npm install -g bs-platform

RUN cd ~ \ 
  && yarn create react-app my-app --scripts-version reason-scripts \
  && cd my-app

WORKDIR /home/app/my-app
  1. yarn start fails. try by: docker run --rm -it sad-reason yarn start
  2. yarn build fails. try by: docker run --rm -it sad-reason yarn build

Sample error:

docker run --rm -it sad-reason yarn start
Failed to compile.

./src/index.re
Module build failed: Error:
/bin/sh: script: not found
    at Array.map (<anonymous>)
    at <anonymous>
error An unexpected error occurred: "Command failed.
Exit signal: SIGINT
Command: sh
Arguments: -c react-scripts start
Directory: /home/app/my-app
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/home/app/my-app/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Default Tests Not Found

Hello,

I'm using the latest 1.0.0-beta4 and when I do a yarn test the test that's included does not run. I'm pretty sure at some point in the past it did run however. I'm more than happy to setup a repro and give more info but I wasn't sure if this was a known problem.

However, i've figured out how to narrow it down and make those tests pass.

Option 1
First I have to remove the .bs.js to get it to see the js file then change the _test to .test... eg change app_test.bs.js to app.test.js then jest picks up the file and shows me the pass/fail as expected. This isn't useable of course but at least shines some light onto a file pattern matching issue.

Option 2
Put the tests in a __tests__ directory and turn on subdirs in the bsconfig.

OSX 10.12.4
bs-platform - 4.0.3
1.0.0-beta-4

Thanks for all you're hard work! ๐Ÿบ ๐ŸŽ‰

I am using npm and 'npm start' did not work complained of missing

I am on ubuntu 17.10.
New install of reason-cli.
Then installed bs-platform and create-react-app as in the example here.

Running npm start gave me the following error

./node_modules/reason-react/lib/js/src/ReactDOMRe.js
Module not found: Can't resolve 'bs-platform/lib/js/caml_array.js' in '/home/rluiten/cra2/node_modules/reason-react/lib/js/src'

I figured out I need to do a npm install before the npm start then things worked.

Just thought I would mention it as it stumped me for 10 minutes.

Display the same warning for every single files

Not sure if I did something wrong, but having one warning on my project (inside ./src/libs/Dict.re file) will actually display it as many time as I have files inside the project minus one, the file actually having the warning. Running yarn start.

Compiled with warnings.

./src/frontend/account/Login.re
Warning number 27
  /Users/pauldijou/Work/projects/adlm/src/libs/Dict.re 13:12-16

  11 โ”‚     switch (get(key, dict) |> updater) {
  12 โ”‚     | None => dict
  13 โ”‚     | Some(value) => dict
  14 โ”‚     };
  15 โ”‚ };

  unused variable value.

./src/index.re
Warning number 27
  /Users/pauldijou/Work/projects/adlm/src/libs/Dict.re 14:15-17

  12 โ”‚     };
  13 โ”‚
  14 โ”‚ let remove = (key, dict) => {
  15 โ”‚     /* if (has(key, dict)) {
  16 โ”‚         Js.Dict.unsafeDeleteKey(dict, key);

  unused variable key.

./src/app.re
Warning number 27
  /Users/pauldijou/Work/projects/adlm/src/libs/Dict.re 14:15-17

  12 โ”‚     };
  13 โ”‚
  14 โ”‚ let remove = (key, dict) => {
  15 โ”‚     /* if (has(key, dict)) {
  16 โ”‚         Js.Dict.unsafeDeleteKey(dict, key);

  unused variable key.

./src/libs/Html.re
Warning number 27
  /Users/pauldijou/Work/projects/adlm/src/libs/Dict.re 14:15-17

  12 โ”‚     };
  13 โ”‚
  14 โ”‚ let remove = (key, dict) => {
  15 โ”‚     /* if (has(key, dict)) {
  16 โ”‚         Js.Dict.unsafeDeleteKey(dict, key);

  unused variable key.

./src/libs/Events.re
Warning number 27
  /Users/pauldijou/Work/projects/adlm/src/libs/Dict.re 14:15-17

  12 โ”‚     };
  13 โ”‚
  14 โ”‚ let remove = (key, dict) => {
  15 โ”‚     /* if (has(key, dict)) {
  16 โ”‚         Js.Dict.unsafeDeleteKey(dict, key);

  unused variable key.

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

Cannot start/build new project

Cannot start/build project.
reproduce steps:

$ npm install -g bs-platform create-react-app
$ create-react-app <app-name> --scripts-version reason-scripts
$ cd <app-name>
$ npm start

error:

yarn run v1.5.1
$ react-scripts build
Creating an optimized production build...
Failed to compile.

./src/index.re
[1/4] Building src/ReactDOMRe.mlast
FAILED: src/ReactDOMRe.mlast
/usr/local/lib/node_modules/bs-platform/lib/bsc.exe -pp "/usr/local/lib/node_modules/bs-platform/lib/refmt3.exe --print binary"    -w -30-40+6+7+27+32..39+44+45+101 -nostdlib -I '/Users/duc/Documents/whiteMouse/my-app/node_modules/bs-platform/lib/ocaml' -bs-no-version-header -no-alias-deps -color always -c -o src/ReactDOMRe.mlast -bs-syntax-only -bs-binary-ast -impl /Users/duc/Documents/whiteMouse/my-app/node_modules/reason-react/src/ReactDOMRe.re
File "/Users/duc/Documents/whiteMouse/my-app/node_modules/reason-react/src/ReactDOMRe.re", line 26, characters 6-7:
Error: 2960: <UNKNOWN SYNTAX ERROR>
File "/Users/duc/Documents/whiteMouse/my-app/node_modules/reason-react/src/ReactDOMRe.re", line 1:
Error: Error while running external preprocessor
Command line: /usr/local/lib/node_modules/bs-platform/lib/refmt3.exe --print binary '/Users/duc/Documents/whiteMouse/my-app/node_modules/reason-react/src/ReactDOMRe.re' > /var/folders/q0/wxdkdc6j6057dgsmwcyrqp5c0000gp/T/ocamlpp1f879d

[2/4] Building src/ReasonReact.mlast
FAILED: src/ReasonReact.mlast
/usr/local/lib/node_modules/bs-platform/lib/bsc.exe -pp "/usr/local/lib/node_modules/bs-platform/lib/refmt3.exe --print binary"    -w -30-40+6+7+27+32..39+44+45+101 -nostdlib -I '/Users/duc/Documents/whiteMouse/my-app/node_modules/bs-platform/lib/ocaml' -bs-no-version-header -no-alias-deps -color always -c -o src/ReasonReact.mlast -bs-syntax-only -bs-binary-ast -impl /Users/duc/Documents/whiteMouse/my-app/node_modules/reason-react/src/ReasonReact.re
File "/Users/duc/Documents/whiteMouse/my-app/node_modules/reason-react/src/ReasonReact.re", line 82, characters 2-3:
Error: 373: <UNKNOWN SYNTAX ERROR>
File "/Users/duc/Documents/whiteMouse/my-app/node_modules/reason-react/src/ReasonReact.re", line 1:
Error: Error while running external preprocessor
Command line: /usr/local/lib/node_modules/bs-platform/lib/refmt3.exe --print binary '/Users/duc/Documents/whiteMouse/my-app/node_modules/reason-react/src/ReasonReact.re' > /var/folders/q0/wxdkdc6j6057dgsmwcyrqp5c0000gp/T/ocamlppe8825f

ninja: error: rebuilding 'build.ninja': subcommand failed
Failure: /usr/local/lib/node_modules/bs-platform/lib/ninja.exe
 Location: /Users/duc/Documents/whiteMouse/my-app/node_modules/reason-react/lib/bs


error An unexpected error occurred: "Command failed.
Exit code: 1
Command: sh
Arguments: -c react-scripts build
Directory: /Users/duc/Documents/whiteMouse/my-app
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/Users/duc/Documents/whiteMouse/my-app/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Default import not working?

What I'm trying to do:

I'm taking an exisiting create-react-app project that I've added bsb into and has been working so far. I just run bsb along side the JS server. However I found it hard to get Jest to work properly so I was trying to switch to this. It seemed like it would be a better experience overall.

What is happening

When I try to do a react-scripts start on the project I get this:

image

Any idea what might be causing this? It seems to complain on default imports everywhere which we use a lot of.

BS Compiler stuck

Whenever I make a change, the compiler compiles just as it should. However in around 70% of cases, the compiler get's stuck, and it just says Compiling... in the terminal.
I then have to stop the compiler and hit npm run again, and then the compiler works just fine for the first compilation, but then gets stuck again the first time or second time I recompile.

Side Notes: I already looked into filewatching via inotify and changed it to a higher amount.
I am using Ubuntu 18.04.01

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.