Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[orion-dev] Source maps & changes to .html files

As of today, source maps are enabled in Orion builds. In Chrome and (probably) Firefox, they should allow you to set breakpoints and step through a minified build of Orion while viewing the un-minified source code in your debugger.

I also removed some old build-time hacks that dealt with AMD module IDs. For the sake of sanity I won't describe those in detail here, however please note that from now on, any new pages or plugins you create must follow a different pattern than before (see below).

What should new pages look like?
When creating a new page or plugin that needs to be optimized, ensure your HTML file loads the full module id of your initialization code ("glue code") in its require() call.

WRONG:
require(["pageLinksPlugin.js"]);   // filename, bad
require(["_javascript_Plugin.js"]);  // filename, bad

RIGHT:
require(["plugins/pageLinksPlugin"]);             // module id, good
require(["_javascript_/plugins/_javascript_Plugin"]); // module id, good

If you fail to do this, your page may seem OK at development time, but it will fail in the optimized Orion build by appearing empty (files load, but nothing happens).

When writing non-production code (such as tests, samples, etc), you can ignore this advice. Strictly speaking, the problem here only arises when you're loading a module that has had its dependencies inlined by the RequireJS optimizer.

What happened to built-foo.js?
Optimized pages are not renamed to built-{whatever}.js anymore. Instead they keep the same name they have at development time.

Where is the un-minified source?
To find the unminified source of any module, just append ".src" onto its URL. For example the un-minified source of /edit/edit.js is /edit/edit.js.src

In general, there are 3 interesting files for every module:
  • edit.js (Minified source file)
  • edit.js.src (Un
    ​-​
    minified source
    ​file)
  • edit.js.map (Source map)

What's the point?
With these changes, the build is more flexible, so we can experiment with ways of packaging Orion code that were difficult before, such as:
  • Load an optimized module from an entry point that is not an HTML file (eg. a web worker)
  • ​Load an optimized module from > 1 HTML file​
  • Load​
    ​ certain features on demand, instead of 1 huge kitchen-sink blob
  • Split pages into optimized modules providing finer-grained units of functionality
​Mark​

Back to the top