Skip to content

Conflict with webpack and ember-auto-import v2 in an emberjs project #357

@les2

Description

@les2

In an EmberJS project, I upgraded to ember-auto-import v2 and i get a single test failure with a webpack related exception. I'm wondering if there could be a conflict between this library (pretender) and webpack?

Pretender intercepted GET webpack://__ember_auto_import__/./node_modules/fake-xml-http-request/src/fake-xml-http-request.js? but no handler was defined for this type of request

Other uses of Pretender in the tests are working fine. There's nothing unusual to my eyes about how it's being used here.

I have the usual passthrough configured like this:

    const server = new Pretender();
    server.prepareHeaders = function(headers) {
      headers[ 'content-type' ] = 'application/vnd.api+json';
      return headers;
    };
    server.get('/**', server.passthrough);

pretender version is 3.4.7
ember is 3.12
ember-auto-import is 2.4.3

Update

I added a handler for unhandled requests like this:

    server.unhandledRequest = function(verb, path, request) {
      if (path.startsWith('webpack://')) {
        request.passthrough();
      } else {
        console.error(`Unhandled request: ${verb} ${path}`);
        throw new Error(`Unhandled request: ${verb} ${path}`);
      }
    };

which results in this error being logged:

'webpack://__ember_auto_import__/./node_modules/fake-xml-http-request/src/fake-xml-http-request.js?' 
from origin 'http://localhost:7357' has been blocked by CORS policy: 
Cross origin requests are only supported for protocol schemes: http, data, isolated-app, 
chrome-extension, chrome, https, chrome-untrusted.

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