Skip to content

najax not present when using jQuery in v0.4/v0.5 #471

@runspired

Description

@runspired

I'm trying to update ember-data's fastboot tests from v0.2. v0.3 works fine.

Starting in 0.4 however @ember/jquery seems to fail to correctly import jquery into the vendor shim and thus no jQuery global is present. No other dependencies are being changed and our fastboot version, ember-source version, and @ember/jquery is the latest release in all cases.

I haven't been able to determine what changed between 0.3 and 0.4 to trigger this (there are very few changes that aren't dependency changes), but wanted to surface this here in case anyone using jQuery still bumps into an error telling them they need to install ember-fetch after upgrading to 0.4 or 0.5.

Edit: after looking through the codepaths it seems the jQuery global check was a red herring, it's always false in fastboot. When using jQuery najax needs to be installed, this used to be brought by fastboot itself but that support was changed in 3.x which v0.4 here bumped to (a deprecation would have been nice, but oh well). The solution here was to install the beta of ember-cli-fastboot 3.x, the latest fastboot, the latest najax, and to configure config/fastboot-testing.js

module.exports = {
  resilient: true,
  buildSandboxGlobals(defaultGlobals) {
    const additionalGlobals = {};
    try {
      const najax = require('najax'); // eslint-disable-line
      additionalGlobals.najax = najax;
    } catch (e) {
      // we only add the global if najax is installed
    }
    return Object.assign({}, defaultGlobals, additionalGlobals);
  },
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions