ember-fastboot / ember-cli-fastboot

Server-side rendering for Ember.js apps
http://ember-fastboot.com/
MIT License
852 stars 160 forks source link

@formatjs is not working with fast boot #791

Open gedaiu opened 3 years ago

gedaiu commented 3 years ago

It looks like fat boot it is not working with the latest @formatjs poyfills. Is there a workaroun this? everything works fine if I don't run fastboot.

ember-cli-build.js

...
babel: {
      plugins: [ require.resolve('ember-auto-import/babel-plugin'), "transform-optional-chaining" ]
    }
...

App is being served by FastBoot
/tmp/broccoli-130391zwtRy0DpAwx/out-618-append_ember_auto_import_analyzer/assets/vendor.js:141913
      return formatterInstance.format(value, formatOptions?.unit ?? formatterOptions.unit);
                                                           ^

SyntaxError: Unexpected token '.'
    at new Script (vm.js:88:7)
    at VMSandbox.eval (/home/gedaiu/workspace/gis-collective/frontend/web-frontend/node_modules/fastboot/src/vm-sandbox.js:13:22)
    at /home/gedaiu/workspace/gis-collective/frontend/web-frontend/node_modules/fastboot/src/ember-app.js:190:15
    at Array.forEach (<anonymous>)
    at EmberApp.loadAppFiles (/home/gedaiu/workspace/gis-collective/frontend/web-frontend/node_modules/fastboot/src/ember-app.js:187:21)
    at EmberApp.retrieveSandboxedApp (/home/gedaiu/workspace/gis-collective/frontend/web-frontend/node_modules/fastboot/src/ember-app.js:235:10)
    at new EmberApp (/home/gedaiu/workspace/gis-collective/frontend/web-frontend/node_modules/fastboot/src/ember-app.js:61:21)
    at FastBoot._buildEmberApp (/home/gedaiu/workspace/gis-collective/frontend/web-frontend/node_modules/fastboot/src/index.js:114:17)
    at new FastBoot (/home/gedaiu/workspace/gis-collective/frontend/web-frontend/node_modules/fastboot/src/index.js:52:10)
    at /home/gedaiu/workspace/gis-collective/frontend/web-frontend/node_modules/ember-cli-fastboot/index.js:335:29
    at Layer.handle [as handle_request] (/home/gedaiu/workspace/gis-collective/frontend/web-frontend/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/home/gedaiu/workspace/gis-collective/frontend/web-frontend/node_modules/express/lib/router/index.js:317:13)
    at /home/gedaiu/workspace/gis-collective/frontend/web-frontend/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/home/gedaiu/workspace/gis-collective/frontend/web-frontend/node_modules/express/lib/router/index.js:335:12)
    at next (/home/gedaiu/workspace/gis-collective/frontend/web-frontend/node_modules/express/lib/router/index.js:275:10)
    at /home/gedaiu/workspace/gis-collective/frontend/web-frontend/node_modules/ember-cli/lib/tasks/server/middleware/broccoli-watcher/index.js:54:11
SergeAstapov commented 3 years ago

@gedaiu please follow https://github.com/ember-fastboot/ember-cli-fastboot/issues/764#issuecomment-662424556 for a solution (TL;DR add node: current to config/targets.js).

Upstream fix is part of latest v3 beta, see #770 for details

mansona commented 3 years ago

@SergeAstapov the upstream fix will only apply in the case that you install ember-cli-fastboot using ember install. It uses the default blueprint to apply node: current to your targets file.

There will be a follow-on feature where we will error if there is not node version defined in your targets file so the issue will be crystal clear to end-users that the need to add it 👍