minderlabs / demo

Minder Demo App
1 stars 0 forks source link

googleapis breaks prod #50

Closed adamberenzweig closed 7 years ago

adamberenzweig commented 7 years ago

Probably some dependency (request?) doesn't play well w/ webpack.

rich sez: right we've seen that before in node i put the previous random fix http://webpack.github.io/docs/configuration.html#node but still doesn't work also the webpack build complains that swig and js-beauty aren't found (only in the script -- not locally) but when i add them it still doesn't work

adamberenzweig commented 7 years ago

taking a look at this.

adamberenzweig commented 7 years ago

Banged my head against it for a few hours. Fix for now is to add googleapis as a direct dependency of sub/apollo. Not sure what the right thing long term is.

Here's what I learned.

  1. googleapis doesn't play well with webpack -- it internally does a filesystem read to introspect it's "apis" directory (generated code). This fails when webpacked.

  2. I tried to build without bundling googleapis, but that's complicated:

    1. Need to exclude googleapis from the bundle, but it gets into the nodeExternals whitelist because of the symlinks made by npm-workspace.
    2. If not bundling, will need to get googleapis into the Docker image's node_modules, because package.json only brings in deps from sub/apollo, not from other minder-XXX libs.

I tried the following:

  1. changed create_package_files.py to fix (ii) by pulling in the other deps. That does indeed get them into the docker file.
  2. Added more nodeExternals() calls to webpack-server externals, hoping that would get googleapis out of the bundle. It didn't work, don't know why.

So then I just added googleapis as a direct dependency of sub/apollo, and it works.

I don't what's the right thing long-term. The current overall approach may continue to cause problems because we're running webpack in one context (sub/apollo) and then sticking a package.json into the docker environment to install things. but because of npm-workspace, the environments are fairly different.

I'll make a PR to revert the reversion of googleapis and the fix, but not till later tonight.

adamberenzweig commented 7 years ago

Closing this for now -- the workaround works (adding googleapis as direct dependency of sub/apollo). I'll file a separate issue about webpack and the docker build.