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

Allow exporting queries directly #18

Closed
jgierer12 opened this issue Nov 8, 2018 · 7 comments

Comments

@jgierer12
Copy link

@jgierer12 jgierer12 commented Nov 8, 2018

import { createQuery } from 'blade.macro';

export const pageQuery = createQuery();

const App = data => {
  const DATA = pageQuery(data);
  const movie = DATA.movie;
};

Currently, this throws an error:

blade.macro: You can't replace this node, we've already removed it

For now, the following workaround is required to do this:

import { createQuery } from 'blade.macro';

const query = createQuery();

export const pageQuery = query;

const App = data => {
  const DATA = query(data);
  const movie = DATA.movie;
};
@sw-yx

This comment has been minimized.

Copy link
Owner

@sw-yx sw-yx commented Nov 9, 2018

nice catch! should be an easy one to fix, thankfully. how do you like it otherwise?

@sw-yx

This comment has been minimized.

Copy link
Owner

@sw-yx sw-yx commented Nov 9, 2018

@sw-yx sw-yx closed this in 8bc5551 Nov 9, 2018
@jgierer12

This comment has been minimized.

Copy link
Author

@jgierer12 jgierer12 commented Nov 11, 2018

Awesome, thanks for the quick fix. I'm a fan of the project so far, but it's not quite production ready. I'll be closely watching it though!

If there are any opportunities to contribute, let me know. I haven't worked with the babel API before, but I'd love to try my hands on a simpler issue.

@sw-yx

This comment has been minimized.

Copy link
Owner

@sw-yx sw-yx commented Nov 12, 2018

haha, yeah its not production ready. needs people who are not me to think of edge cases i cant think of!

the babel api is pretty big. def read jamie kyle's handbook first. that took me a good 2-3 tries before i really got thru all of it. then work on smaller babel plugins that reverse letters or swap out function expressions for arrow function expressions. then read up on @kentcdodds' babel macros writing.

i'll be doing a complete ground up typescript rewrite of babel-blade anyway as the bugs have been bothering me too much so i'll be sure to livestream/record that.

@kentcdodds

This comment has been minimized.

Copy link
Contributor

@kentcdodds kentcdodds commented Nov 12, 2018

i'll be sure to livestream/record that.

💯👍👏

@sw-yx

This comment has been minimized.

Copy link
Owner

@sw-yx sw-yx commented Nov 12, 2018

oh lol: https://dev.doctorevidence.com/how-to-write-a-typescript-transform-plugin-fc5308fdd943 i might need to just write a typescript transform...

babel doesnt seem to have typescript typings which is either an opportunity (a lot of work) or a problem (do we stay in babel and be potentially buggy or make a typescript plugin and alienate js users or maintain both cos we are masochists

@kentcdodds

This comment has been minimized.

Copy link
Contributor

@kentcdodds kentcdodds commented Nov 12, 2018

Please do not opt for a typescript transform....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.