Skip to content

Drop FastBoot.require for 3rd dependencies? #251

@bobisjan

Description

@bobisjan

Hello,

according to the upcoming major release, would it make sense to drop custom FastBoot import system and use what JavaScript has by spec?

Some benefits could be

  • following the spec,
  • simplifying FastBoot build process.

3rd dependencies

For importing external modules from 3rd packages the ember-auto-import could be used.

  1. Add dependencies as usual npm install --save-dev ldclient-node ldclient-js.

  2. Use dynamic import to conditionally import modules in FastBoot / browser.

// simplified example

let ldclient;

if (typeof FastBoot !== 'undefined') {
  ldclient = await import('ldclient-node');
} else {
  ldclient = await import('ldclient-js');
}

Node.js built-in modules

FastBoot.require will be still used for importing Node.js builtins at runtime, however it could be marked "private", because only ember-auto-import should use it at compile time, add-ons/applications will use native JavaScript.

// input
import os from 'os';
const os = await import('os');

// output
const os = FastBoot.require('os'); 
const os = await FastBoot.require('os');

I'm not sure if I'm missing something that could prevent from dropping FastBoot.require now.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions