Skip to content

Transpile x=require(y?'foo':'bar') to require('foo');require('bar');x=require(y?'foo':'bar'); #12

Description

@arian

If the require() module name is dynamically determined with a ternary, which has two strings, requiring both modules first, to make sure they are both available.

Somehow wrapup already fixes this almost, but when outputing it as AMD, and using requirejs, and one of the modules is not yet loaded yet, then requirejs does not statically load both modules upfront, so it will require(x?'a':'b') while a or b are not defined yet, resulting in an error. If prefixing require('a'); require('b') requirejs will make sure both modules are loaded, before doing the require(x?'a':'b');.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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