Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Scope-nested AMD defines not being named #228

Closed
guybedford opened this issue Jul 12, 2015 · 2 comments
Closed

Scope-nested AMD defines not being named #228

guybedford opened this issue Jul 12, 2015 · 2 comments

Comments

@guybedford
Copy link
Member

Example scenario is toastr - https://github.com/32graham/jspm-toastr-bundle-problem.

We should use a create define method in the bundle that gives the name to the createDefine function itself. Then this will work with arbitrary nesting / define variable passing.

@guybedford
Copy link
Member Author

These are named correctly by r.js, so since this sets the AMD precendent, it is fine to adapt the transformer to these cases.

After some investigation, it seems r.js does the following transforms in https://github.com/jrburke/r.js/blob/master/build/jslib/transform.js:

  1. Visit the whole parse tree, with no scope analysis
  2. Stop on a var define assignments unless it is a var define = require('amdefine')(module) case.
  3. If there is a define() call with arguments, it then attempts to match the AMD define forms, skipping if it doesn't match the expected signature calls. Named defines are fully handled with dependencies inserted from CJS factory forms, just not assigned ids.

Of the above the primary change seems to be that function argument closures of define are treated as the same define, while define assignments are seen as scope stop rules only.

This is strange, but the ecosystems to be implicitly built around this rule, so we can try to match that.

@guybedford
Copy link
Member Author

Released in 0.13.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant