question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unintended FastBoot dependencies under Embroider

See original GitHub issue

Hi,

I have a question about content of dist/package.js under FastBoot. It looks that the dist/package.json is extended version of package.json with FastBoot extras.

In classic build the dist/package.json contains dependencies based on fastbootDependencies in package.json, then npm install is required to run in dist/ (eq. fastboot-s3-downloader).

{
  "dependencies": {
    "abortcontroller-polyfill": "^1.4.0",
    "node-fetch": "^2.6.1"
  }
}

When using Embroider the dist/package.json contains also references for in-repo add-ons, thus later run of npm install fails.

{
  "dependencies": {
    "aws": "*",
    "build": "*",
    "dom-attrs": "*",
    "gtm": "*",
    "headers": "*",
    "manifest": "*",
    "one-signal": "*",
    "redirect-support": "*",
    "sitemap": "*",
    "test-fastboot": "*",
    "version": "*",
    "abortcontroller-polyfill": "^1.4.0",
    "node-fetch": "^2.6.1"
  }
}

How these extra dependencies should be handled in FastBoot?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ef4commented, Feb 12, 2021

Ah, that is a good question. Some additional config is going to be required to make that work. You would need to tell webpack to treat them as externals. Something like this:

return require('@embroider/compat').compatBuild(app, Webpack, {
  packagerOptions: {
     webpackConfig: {
       externals: {
         fs: "require('fs')"
       }
     }
  }
});
0reactions
bobisjancommented, Feb 13, 2021

Thanks for clarification, before I dive in I’ve made an example of the changes.

// before
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default IndexRoute extends Route {
  @service fastboot;

  model() {
    if (this.fastboot.isFastBoot) { // or typeof FastBoot !== 'undefined'
      let process = FastBoot.require('process'); // Node.js built-in
      let something = FastBoot.require('something'); // 3rd package
      
      return `${process.title}:${something}`;
    } else {
      return 'other';
    }
  }
}

// after
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { importSync } from '@embroider/macros';

export default IndexRoute extends Route {
  @service fastboot;

  model() {
    if (this.fastboot.isFastBoot) { // or typeof FastBoot !== 'undefined'
      let process = require('process'); // Node.js built-in
      let something = importSync('something'); // 3rd package

      return `${process.title}:${something}`;
    } else {
      return 'other';
    }
  }
}
  1. https://github.com/embroider-build/embroider/blob/936367159b370492b0bff4b67373d1da29d49fd3/packages/core/src/babel-plugin-adjust-imports.ts is this correct place to the job?
  2. this.fastboot.isFastBoot or typeof FastBoot !== 'undefined' will work properly or macroCondition(getGlobalConfig().fastboot?.isRunning) should be used instead to avoid bundling something into browser assets?
Read more comments on GitHub >

github_iconTop Results From Across the Web

embroider/SPEC.md at main - GitHub
the fastboot transform is used to neuter whole dependencies in fastboot. This can be handled by ECMA dynamic import() instead. most other occurrences...
Read more >
Build Issues - Ember.JS
Topic Replies Views Activity About the Build Issues category 0 578 April 9, 2018 Importing host app components in Embroider Addon 1 106 October 26,...
Read more >
@embroider/macros | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
EmberConf 2021 Notes - Alex DiLiberto
Glimmer 2: drop in replacement in Ember 2.10 (complete rewrite ... Status of major ecosystem projects like Fastboot, Embroider and Engines?
Read more >
Newest 'ember.js' Questions - Stack Overflow
How to create a dependency graph of components in Ember? I'm trying to navigate through a large Ember ... Module parse failed: Unexpected...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found