Skip to content

Define Incorrectly Updated When No Dependencies And Function Wrapped In Parentheses #1007

@davehawkins4f

Description

@davehawkins4f

There is a javascript performance optimisation where functions supplied as arguments are wrapped in parentheses. This is applied, for example, by the terser minifier. This confuses r.js when a define has no dependencies and it incorrectly updates the call:

test.js - original module

define(function () {});

test_min.js - generated by, eg, terser

define((function(){}));

test_bundle.js - r.js -o name=test paths.test=test_min out=test_bundle.js optimize=none

define(('module_name',[],function(){}));

The arguments have been incorrectly inserted inside the parentheses surrounding the function rather than as arguments to the define call.

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