Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usage: how to run farrow with esno ? #127

Closed
yolio2003 opened this issue Nov 16, 2021 · 13 comments
Closed

usage: how to run farrow with esno ? #127

yolio2003 opened this issue Nov 16, 2021 · 13 comments

Comments

@yolio2003
Copy link

yolio2003 commented Nov 16, 2021

  1. Can't find the entrance to run farrow separately, can't it run independently without farrow cli? (It seems that there is only one more generation step)
  2. The default interface generated by farrow cli will automatically send a request. Is there a configuration to turn off this? cause it looks weird.
  3. how to get a esm verion of farrow-api-client, so i can use it quickly
@yolio2003 yolio2003 changed the title useage: how to run farrow with esno ? usage: how to run farrow with esno ? Nov 16, 2021
@Lucifier129
Copy link
Collaborator

Lucifier129 commented Nov 16, 2021

Can't find the entrance to run farrow separately, can't it run independently without farrow cli? (It seems that there is only one more generation step)

You mean the node.js api of farrow ?

It can be used like below.

import { build } from 'farrow/dist/build'
import { start } from 'farrow/dist/start'
import { dev } from 'farrow/dist/dev'

await build({...config})

The default interface generated by farrow cli will automatically send a request. Is there a configuration to turn off this? cause it looks weird.

This feature can be turned off.

// farrow.config.js

module.exports = {
 // for connecting farrow-api-server and codegen farrow-api-client
  api: [
     {
       src: 'http://localhost:3002/api/todo',
       dist: `${__dirname}/src/api/todo.ts`,
       codegen: {
             /**
             * emit createApiClient or not
             * if set to false, only types will be codegened
             */
           emitApiClient:  false
       }
     },
   ],
}

But why do you want to turn off it? It's very useful for communicating with the server automatically.

how to get a esm verion of farrow-api-client, so i can use it quickly

There is no explicit plan for ESM support. We used to emit ESM version but encounter some wired bug in node.js/webpack/esbuild toolings and can figure out what's happening, so we turn off it.

When the js/ts community is ready enough for ESM modules, we will enable the feature.

@yolio2003
Copy link
Author

yolio2003 commented Nov 16, 2021

got it , thx master,

for "1" looks it has some error tips, maybe should provide a more easy way from source not dist.

for "2" cause it just a bit noise for me. already done now, thx.

for "3", i mean only wana have the farriow-api-client ems version as chrome already support importmap, so we can use this in client quickly.

for "3" maybe not esm version iife version is ok too.(in face i can use vite to compiled this.)

@yolio2003 yolio2003 reopened this Nov 16, 2021
@yolio2003
Copy link
Author

yolio2003 commented Nov 16, 2021

sorry for "2", what i want is not disable the config, i only want to remove the noise log
image

the feature is useful, the log is trigger by the auto request? i think i don't need this, don't find any code that trigger this.(correct me if i'm wrong)

@Lucifier129
Copy link
Collaborator

@yolio2003 farrow-http v1.10.10 had released a new feature that will disable introspection request log by default.

Try it out~

@yolio2003
Copy link
Author

got it thx! i think you can do this in 10 seconds by default, if you want to show the feature.

@yolio2003
Copy link
Author

hey boss, i have successly run with node --experimental-loader esbuild-node-loader ./src/index.ts, and i haven't get error during running process.
then i found that

  1. server bundle to CJS will get some error, i can ignore this, cause i use esbuild-node-loader, and it works well
  2. so i tried just use client complied, i found that it deps on api, but it also scan the src/index.ts and trigger some error, that is not necessary!
  3. however, finally i change code to run this, but it's bad DX,

so the idea is can we just complied from the src/api/ so i can move the error deps (like lowdb ...) from /src/api to /src/index.ts, then i think everything should works well ?

sorry for nagging again.

@yolio2003
Copy link
Author

image
image
image

this is some error capture, but all not big error. =.=

@tqma113 tqma113 reopened this Nov 17, 2021
@tqma113
Copy link
Collaborator

tqma113 commented Nov 17, 2021

Does here need two build outputs, commonjs and esm?

@tqma113
Copy link
Collaborator

tqma113 commented Nov 17, 2021

@Lucifier129
Copy link
Collaborator

@yolio2003 Are you trying to use farrow-http as ESM Modules? It currently does not support ESM..

@yolio2003
Copy link
Author

Does here need two build outputs, commonjs and esm?

no, just need emitApiClient to be correct.

@yolio2003 Are you trying to use farrow-http as ESM Modules? It currently does not support ESM..

yes, i run with node --experimental-loader esbuild-node-loader ./src/index.ts, it works very well (i can ignore import issue)

can we only deps on /src/api ? cause i need to do this:

  1. run my app with esbuilder
  2. remove the import from "lowdb" remove the not support syntax await __dirname ...
  3. modify and fix import issue
  4. run yarn run dev > a. start server >b. build to /client/todo.ts > c. synced /client/todo.ts
  5. fallback step 2

so the question is, should the clientApi step should only deps on these ?

  1. http://xxx.com/todo
  2. /src/api type define

@Lucifier129
Copy link
Collaborator

Sorry, we suggest to run farrow app via official tooling like farrow-cli.

It will be a mess if we try to support ESM now. Maybe in the future that the ecosystem is more stable, and the tools around ESM support are more complete, it is time for us to move forward the ESM way.

@yolio2003
Copy link
Author

ok just discuss the clientApi codegen's dependences. that's ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants