treycordova / nativejsx

JSX to native DOM API transpilation. :yellow_heart: <div> ⟹ document.createElement('div')!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running nativejsx from npm scripts

asunar opened this issue · comments

commented

Is it possible to run nativejsx transpilation by providing source/dest folders i.e. do exactly what gulp-nativejsx is doing without the gulp dependency?

I imagine something like this in package.json

   "scripts": {
    "build": "nativejsx www\\src --out www\\dist\"
   }

Transpile the file under src folder and save the output in dist folder

Thanks.

Hmm, I haven't considered it, but I could see how that would be nice to have. I'll see if I can get something working over the weekend.

commented

Thanks.

On Apr 9, 2016, at 7:19 AM, Trey Cordova notifications@github.com wrote:

Hmm, I haven't considered it, but I could see how that would be nice to have. I'll see if I can get something working over the weekend.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub

Alright, there's a basic implementation sitting in master under bin/.

Here's an example to get you started:

$ bin/nativejsx test/**/*.jsx --output compiled/

Let me know if this works for your purposes. If so, either you or I can close out this issue.

Thanks.

commented

Hi @treycordova,
Thanks for the quick response.

I tested the implementation here are my comments:

  1. bin folder does not seem to be part of the npm package. Ran npm install nativejsx in a new folder, did not get the bin folder. Can you add it to the package so that npm install will create the bin folder?

  2. After manually downloading the bin folder. I tried to run nativejsx from npm scripts section. It only worked successfully when I ran it from the command line like this:

node node_modules\nativejsx\bin\nativejsx ./test/repro.js --output compiled/

I was hoping to run nativejsx with npm run.
In package.json, if there is a build command in scripts section like this:

   "scripts": {
    "build": "nativejsx test/**/*.jsx --output compiled/"
   }

I would like to run nativejsx like this:
npm run build

Here is a typical implementation. After installing uglifyjs with npm install and adding the following line to package.json

   "scripts": {
    "build": "uglifyjs www\\script-compiled.js -o www\\script-compiled.min.js"
   }

I can run it successfully like this:
npm run build

A better user experience in my opinion because

  1. npm install downloads everything that is needed
  2. User can run the package with npm run xxxxx
  3. User does not have to worry about figuring the full path

Would it be possible to address these issues? I'll see if I can create a pull request to address them.

Thanks.

commented

Looks like adding a bin section to your package.json is a good place to start.
npm and executables

I apologize for not being clearer (also I was in Europe, so I kind of disappeared on you).

I was wondering if the binary worked as you expected without a release of nativejsx. I'm going to go with my confirmation and say it works, and I've added it to bin and cut a release. It's available in 3.1.0 (and installable through npm) and should have the user experience that you desired.

Thanks for all of the suggestions and thanks for helping out, @asunar.

commented

HI @treycordova,
Sorry for pointing out the obvious. I did not realize that you wanted to verify the binary before updating the package.

Thanks for updating the package. It seems to be working with a single file but not with wildcards.
i.e. This works
nativejsx components/repro.js --output dist/

but this does not work
nativejsx components/*.js --output dist/
> Error: ENOENT: no such file or directory, open 'c:\code\mynativejsx\components\*.js'

neither does this
nativejsx components/**/*.js --output dist/
>Error: ENOENT: no such file or directory, open 'c:\code\mynativejsx\components\**\*.js'

When you have some time can you add wildcard support?

Thanks for all the effort.

Mind trying out 2769cbc?

It appears that my shell has glob expansion built into it, or commander utilizes it somehow. I've added a snippet of extra code to see if the path comes back as a string. If so, it will get globbed as if it is a wildcard. Let's hope that works out.

commented

typeof files is object so it does not glob it.

glob

Can I get an output of files to see what we're dealing with?

commented

Looks like It is an array.
glob

Alright, this one (0995154) is going to work (crosses fingers).

commented

It worked..
🎉

Thanks again, much appreciated.

Tagged and published. You can npm update nativejsx. It's now at 3.1.1. I'm going to close this one out.

commented

👍