Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Run one-off script through same babel environment as runtime #466

Open
joenoon opened this issue Aug 6, 2018 · 3 comments
Open

Run one-off script through same babel environment as runtime #466

joenoon opened this issue Aug 6, 2018 · 3 comments

Comments

@joenoon
Copy link

joenoon commented Aug 6, 2018

Type of issue

Feature request

Description

I am trying to run a one-off script - in this case, a graphql schema generator. My script loads the schema and prints out the .json and .graphql files. The schema is also loaded by fusion at runtime.

Current behavior

Because I don't have a babel config (fusion handles this), my script can't run, and can't require anything that is written thinking it will be transpiled.

Expected behavior

I could create my own .babelrc like normal, install babel-cli, etc., but I was hoping for consistency to be able to run it through the exact same config fusion uses to build.

Steps to reproduce

  1. create a file, src/one-off-script.js
  2. add something that needs to be transpiled in the file, like import ...
  3. run script, node src/one-off-script.js

Your environment

  • fusion-cli version: 1.8.4

  • Node.js version (node --version): 8.11.3

  • npm version (npm --version): yarn 1.9.2

  • Operating System: a mess - WSL/ubuntu at work (lol)

@ganemone
Copy link
Contributor

ganemone commented Aug 6, 2018

I think this brings up a use case we might want to add support for. While a custom babel config is an okay workaround, we should probably think about exposing some form of API to make this possible, especially as we start introducing more virtual modules such as createUniversalSymbol which we talked about today (cc @rtsao).

@rtsao
Copy link
Contributor

rtsao commented Aug 7, 2018

@joenoon You might be interested in fusionjs/rfcs#7. Also would you mind expanding on how the code generation stuff works? Are you using a specific babel plugin? What does your script do?

@ganemone
Copy link
Contributor

ganemone commented Aug 7, 2018

I think the point is if you want to have a script that uses any of your application code, you probably want to build it the same way. Especially if it have references to __NODE__, __DEV__, etc.

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

No branches or pull requests

3 participants