brunch / deppack

Extract node modules to browser.
MIT License
4 stars 13 forks source link

possibility to disable envify for selected files? #47

Open leiyangyou opened 7 years ago

leiyangyou commented 7 years ago

this particular string

  return '\n    If you using \'express-graphql\', you may get server stack-trace for error.\n    Just tune \'formatError\' to return \'stack\' with stack-trace:\n\n    import graphqlHTTP from \'express-graphql\';\n\n    const graphQLMiddleware = graphqlHTTP({\n      schema: myGraphQLSchema,\n      formatError: (error) => ({\n        message: error.message,\n        stack: process.env.NODE_ENV === \'development\' ? error.stack.split(\'\\n\') : null,\n      })\n    });\n\n    app.use(\'/graphql\', graphQLMiddleware);';

when envified will break acorn as process.env.NODE_ENV is getting changed to 'development'

shvaikalesh commented 7 years ago

Hi @leiyangyou. Thanks for reaching out.

Can you please try to replace process.env.NODE_ENV with process.env['NODE_ENV']. Does it help?

leiyangyou commented 7 years ago

Thanks. That's exactly what I ended up doing, although it meant that I had to clone and modify a third party library. I understand that doing envify properly would be hard (one way to achieve this is running the code through acorn first, do envify, then regenerate the code from the ast), for now at least it may make sense to have envify become a configurable plugin. I actually didn't know brunch has this functionality built in before and have been using plugins to achieve this. via Newton Mail [https://cloudmagic.com/k/d/mailapp?ct=pi&cv=9.3.50&pv=10.2&source=email_footer_2] On Fri, Dec 30, 2016 at 2:35 PM, Aleksey Shvayka notifications@github.com wrote: Hi @leiyangyou [https://github.com/leiyangyou] . Thanks for reaching out.

Can you please try to replace process.env.NODE_ENV with process.env['NODE_ENV'] . Does it help?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [https://github.com/brunch/deppack/issues/47#issuecomment-269737666] , or mute the thread [https://github.com/notifications/unsubscribe-auth/AAGXzQtJQmqqpWkwutg6skUMmFzqJC4Gks5rNKZJgaJpZM4LX23d] .

shvaikalesh commented 7 years ago

That's exactly what I ended up doing, although it meant that I had to clone and modify a third party library.

That sucks.

Indeed, we will integrate AST-based solution, cause we have too many issues caused by the current one.