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

Questions of Babel Compilation #12

Closed
dtothefp opened this issue Oct 26, 2015 · 4 comments
Closed

Questions of Babel Compilation #12

dtothefp opened this issue Oct 26, 2015 · 4 comments

Comments

@dtothefp
Copy link

This is a question around use of webpack-isomorphic-tools and compilation through babel vs. use of the babel/register.

I have a script that runs similar to the original demo I shared https://github.com/dtothefp/isomorphic-demo/blob/master/app/index.js. Unfortunately, it is on a private repo so I can't share it here.

Essentially, it uses the babel/register and kicks off the process of rendering HTML from a React component. The problem is that this react component imports many internal modules (on our internal NPM registry, some of which are themselves react component libraries) that are written in es6 and NOT pre-compiled. I wrote a small script that uses the babel ignore property to include these external modules in es6 compilation https://babeljs.io/docs/usage/require/#specifying-options and this works great locally, the HTML compiles in about 2 seconds or less.

The problem is we are running this on an AWS lamda, and in that environment, importing the component results in compile times greater than 30s. I would like to pre-compile the modules or potentially pre-compile the whole script that contains the webpack-isomorphic-tools entry i.e.

  tools.development(isDev).server(statsDir).then(() => {
    const runLambda = require('./lambda-function');
     runLambda(templatingArgs, cb);
  });

I'm just wondering if this breaks some of the require magic or if require hooks will still be established regardless by webpack-isomorphic-tools if code is pre-compiled through babel and not run through the babel/register?

@catamphetamine
Copy link
Owner

webpack-isomorphic-tools should work irrelevant of whether you're using Babel or not.
It should be agnostic.

@dtothefp
Copy link
Author

ok great, also does it not matter if I make the tools.development(isDev).server(statsDir) call in the same file that requires the babel/register as long as creating my HTML is inside of the Promise resolve/callback for the server function?

@catamphetamine
Copy link
Owner

As I've already said, webpack-isomorphic-tools should work irrelevant of whether you're using Babel or not.
It should be agnostic of whatever code you're putting it in.

@dtothefp
Copy link
Author

cool thx, closing

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

2 participants