close
Skip to content

CommonJS wrapper doesn't like being bundled #833

@OliverJAsh

Description

@OliverJAsh

I have a third party script which is an optimized AMD file that contains a CommonJS wrapper:

// bar.js
define('bar', function(require) {
    var foo = require("./foo");
});
define('foo', function () {});

When I try to bundle this file into my own file:

// app.js
define(['bar'], function () {});

r.js doesn't notice that foo is already defined within the bar file, leading to:

>> Error: ENOENT, no such file or directory
>> '/Users/OliverJAsh/Development/frontend/foo.js'
>> In module tree:
>>     app

I'm guessing this is because r.js has to perform static analysis of the CommonJS wrapper. What do you recommend to work around this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions