Showing preview only (1,214K chars total). Download the full file or copy to clipboard to get everything.
Repository: requirejs/requirejs
Branch: master
Commit: 7faea6492e19
Files: 644
Total size: 1.1 MB
Directory structure:
gitextract_p4byhwra/
├── .github/
│ └── CONTRIBUTING.md
├── .gitignore
├── .jscsrc
├── .jshintrc
├── .travis.yml
├── LICENSE
├── README.md
├── dist/
│ ├── Markdown-License.text
│ ├── Markdown.pl
│ ├── README.md
│ ├── dist-build.sh
│ ├── dist-site.js
│ ├── file.js
│ ├── fonts/
│ │ └── PT-Sans/
│ │ └── Paratype PT Sans Free Font License.txt
│ ├── init.js
│ ├── post.html
│ └── pre.html
├── docs/
│ ├── api.html
│ ├── commonjs.html
│ ├── contributing.html
│ ├── design/
│ │ └── packages.md
│ ├── dojo.html
│ ├── download.html
│ ├── errors.html
│ ├── faq-advanced.html
│ ├── faq-optimization.html
│ ├── faq.html
│ ├── history.html
│ ├── jquery.html
│ ├── node.html
│ ├── optimization.html
│ ├── plugins.html
│ ├── requirements.html
│ ├── start.html
│ ├── why.html
│ └── whyamd.html
├── index.html
├── package.json
├── require.js
├── tasks.txt
├── testBaseUrl.js
├── tests/
│ ├── NAMESPACE.html
│ ├── afterload.html
│ ├── afterloadreadystate.js
│ ├── all.js
│ ├── anon/
│ │ ├── a.js
│ │ ├── anon-tests.js
│ │ ├── anonSimple.html
│ │ ├── blue.js
│ │ ├── c.js
│ │ ├── green.js
│ │ ├── magenta.js
│ │ ├── message.txt
│ │ ├── red.js
│ │ ├── sub/
│ │ │ └── b.js
│ │ └── yellow.js
│ ├── bar
│ ├── baseUrl.html
│ ├── bundles/
│ │ ├── bundles-tests.js
│ │ ├── bundles.html
│ │ ├── main.js
│ │ ├── second.js
│ │ └── third.js
│ ├── circular/
│ │ ├── 414/
│ │ │ ├── 414-tests.js
│ │ │ ├── 414.html
│ │ │ ├── A.js
│ │ │ ├── B.js
│ │ │ ├── C.js
│ │ │ └── MyClass.js
│ │ ├── a.js
│ │ ├── b.js
│ │ ├── c.js
│ │ ├── circularPlugin-tests.js
│ │ ├── circularPlugin.html
│ │ ├── complexPlugin/
│ │ │ ├── complexPlugin-tests.js
│ │ │ ├── complexPlugin.html
│ │ │ ├── helper.js
│ │ │ ├── main.js
│ │ │ ├── slowText.js
│ │ │ ├── toolbar.html
│ │ │ ├── toolbar.js
│ │ │ ├── viewport.html
│ │ │ └── viewport.js
│ │ ├── dupe/
│ │ │ ├── dupe.html
│ │ │ ├── exported.js
│ │ │ └── func.js
│ │ ├── plugin.js
│ │ └── transpiler/
│ │ ├── a.refine
│ │ ├── b.refine
│ │ ├── c.refine
│ │ ├── d.refine
│ │ ├── e.refine
│ │ ├── transpiler-tests.js
│ │ └── transpiler.html
│ ├── circular-tests.js
│ ├── circular.html
│ ├── cjsSpace/
│ │ ├── a.js
│ │ ├── b.js
│ │ ├── c.js
│ │ ├── cjsDotRequire-tests.js
│ │ ├── cjsDotRequire.html
│ │ ├── cjsSpace-tests.js
│ │ └── cjsSpace.html
│ ├── commentParen/
│ │ ├── a.js
│ │ ├── b.js
│ │ └── commentParen.html
│ ├── commonjs/
│ │ └── tests/
│ │ └── modules/
│ │ └── 1.0/
│ │ ├── absolute/
│ │ │ ├── b.js
│ │ │ ├── program.html
│ │ │ ├── program.js
│ │ │ ├── submodule/
│ │ │ │ └── a.js
│ │ │ └── test.js
│ │ ├── all.html
│ │ ├── cyclic/
│ │ │ ├── a.js
│ │ │ ├── b.js
│ │ │ ├── program.html
│ │ │ ├── program.js
│ │ │ └── test.js
│ │ ├── determinism/
│ │ │ ├── program.html
│ │ │ ├── program.js
│ │ │ ├── submodule/
│ │ │ │ ├── a.js
│ │ │ │ └── b.js
│ │ │ └── test.js
│ │ ├── exactExports/
│ │ │ ├── a.js
│ │ │ ├── program.html
│ │ │ ├── program.js
│ │ │ └── test.js
│ │ ├── hasOwnProperty/
│ │ │ ├── hasOwnProperty.js
│ │ │ ├── program.html
│ │ │ ├── program.js
│ │ │ ├── test.js
│ │ │ └── toString.js
│ │ ├── method/
│ │ │ ├── a.js
│ │ │ ├── program.html
│ │ │ ├── program.js
│ │ │ └── test.js
│ │ ├── missing/
│ │ │ ├── program.html
│ │ │ ├── program.js
│ │ │ └── test.js
│ │ ├── monkeys/
│ │ │ ├── a.js
│ │ │ ├── program.html
│ │ │ ├── program.js
│ │ │ └── test.js
│ │ ├── nested/
│ │ │ ├── a/
│ │ │ │ └── b/
│ │ │ │ └── c/
│ │ │ │ └── d.js
│ │ │ ├── program.html
│ │ │ ├── program.js
│ │ │ └── test.js
│ │ ├── relative/
│ │ │ ├── program.html
│ │ │ ├── program.js
│ │ │ ├── submodule/
│ │ │ │ ├── a.js
│ │ │ │ └── b.js
│ │ │ └── test.js
│ │ ├── system.js
│ │ ├── test.js
│ │ └── transitive/
│ │ ├── a.js
│ │ ├── b.js
│ │ ├── c.js
│ │ ├── program.html
│ │ ├── program.js
│ │ └── test.js
│ ├── config.html
│ ├── configRequirejs.html
│ ├── dataMain/
│ │ ├── baseUrl/
│ │ │ ├── a.js
│ │ │ ├── dataMainBaseUrl.html
│ │ │ └── src/
│ │ │ └── main.js
│ │ ├── dataMain.html
│ │ ├── dataMain.js
│ │ ├── dataMainIndex/
│ │ │ ├── dataMainIndex.html
│ │ │ └── index.js
│ │ ├── dataMainPlugin/
│ │ │ ├── dataMainPlugin.html
│ │ │ ├── modules/
│ │ │ │ └── sub/
│ │ │ │ ├── a.js
│ │ │ │ └── test.js
│ │ │ └── my/
│ │ │ └── plugin.js
│ │ └── skipDataMain/
│ │ ├── a.js
│ │ ├── index.js
│ │ └── skipDataMain.html
│ ├── datauri/
│ │ └── datauri.html
│ ├── defineDouble/
│ │ └── defineDouble.html
│ ├── definedSpecified/
│ │ ├── a.js
│ │ ├── b.js
│ │ ├── definedSpecified-tests.js
│ │ └── definedSpecified.html
│ ├── delayedDefine/
│ │ ├── delayedDefine-tests.js
│ │ └── delayedDefine.html
│ ├── depEmpty.html
│ ├── depoverlap.html
│ ├── depoverlap.js
│ ├── dimple.js
│ ├── doh/
│ │ ├── LICENSE
│ │ ├── README
│ │ ├── _browserRunner.js
│ │ ├── _nodeRunner.js
│ │ ├── _rhinoRunner.js
│ │ ├── _sounds/
│ │ │ └── LICENSE
│ │ ├── runner.html
│ │ ├── runner.js
│ │ └── runner.sh
│ ├── domReady/
│ │ ├── domReady-tests.js
│ │ ├── domReady.html
│ │ ├── domReadyExtraConfig-tests.js
│ │ ├── domReadyExtraConfig.html
│ │ ├── one.js
│ │ └── two.js
│ ├── dos.js
│ ├── dotTrim/
│ │ ├── b.js
│ │ ├── dotTrim-tests.js
│ │ ├── dotTrim.html
│ │ ├── spell.js
│ │ ├── sub/
│ │ │ └── ext.js
│ │ └── util/
│ │ └── helper.js
│ ├── error/
│ │ ├── a.js
│ │ ├── b.js
│ │ ├── c.js
│ │ ├── d.js
│ │ ├── defineError.js
│ │ ├── defineErrorLocal.html
│ │ ├── doubleRequire/
│ │ │ ├── b.js
│ │ │ ├── c.js
│ │ │ └── doubleRequire.html
│ │ ├── errorChild.html
│ │ ├── errorContinue.html
│ │ ├── errorContinueLocal.html
│ │ ├── globalOnError.html
│ │ ├── plug.js
│ │ ├── pluginErrorContinue.html
│ │ ├── pluginErrorContinueLocal.html
│ │ └── requireErrback.html
│ ├── exports/
│ │ ├── am.js
│ │ ├── assign.js
│ │ ├── assign2.js
│ │ ├── bm.js
│ │ ├── cm.js
│ │ ├── exports-tests.js
│ │ ├── exports.html
│ │ ├── funcSet.js
│ │ ├── implicitModule.js
│ │ ├── moduleAndExports-tests.js
│ │ ├── moduleAndExports.html
│ │ ├── simpleReturn.js
│ │ ├── usethis.js
│ │ └── vanilla.js
│ ├── foo
│ ├── func.js
│ ├── funcFour.js
│ ├── funcOne.js
│ ├── funcThree.js
│ ├── funcTwo.js
│ ├── hasOwnProperty/
│ │ ├── hasOwnProperty-tests.js
│ │ ├── hasOwnProperty.html
│ │ ├── hasOwnProperty.js
│ │ ├── prototype.js
│ │ └── toString.js
│ ├── i18n/
│ │ ├── common.html
│ │ ├── commonA.js
│ │ ├── commonB.js
│ │ ├── i18n.html
│ │ ├── nls/
│ │ │ ├── colors.js
│ │ │ ├── en-us-surfer/
│ │ │ │ └── colors.js
│ │ │ └── fr/
│ │ │ └── colors.js
│ │ └── testModule.js
│ ├── index.html
│ ├── isBrowser/
│ │ ├── a.js
│ │ ├── isBrowser-tests.js
│ │ └── isBrowser.html
│ ├── issue379/
│ │ ├── issue379.html
│ │ └── issue379.js
│ ├── jquery/
│ │ ├── jquery.html
│ │ ├── jqueryDynamic.html
│ │ ├── jqueryDynamic2.html
│ │ └── scripts/
│ │ ├── app.js
│ │ ├── dynamicApp.js
│ │ ├── jquery-1.7.1.js
│ │ ├── jquery-GPL-LICENSE.txt
│ │ ├── jquery-MIT-LICENSE.txt
│ │ ├── jquery.alpha.js
│ │ ├── jquery.beta.js
│ │ ├── jquery.epsilon.js
│ │ └── jquery.gamma.js
│ ├── jsonp/
│ │ ├── jsonp.html
│ │ ├── lamp.js
│ │ └── twitter.html
│ ├── layers/
│ │ ├── build.sh
│ │ ├── epsilon.js
│ │ ├── helloWorld.txt
│ │ ├── layer1.js
│ │ └── layers.html
│ ├── map.js
│ ├── mapConfig/
│ │ ├── a1/
│ │ │ └── sub/
│ │ │ └── one.js
│ │ ├── a1.js
│ │ ├── adapter/
│ │ │ └── d.js
│ │ ├── another/
│ │ │ ├── c/
│ │ │ │ ├── dim.js
│ │ │ │ └── sub.js
│ │ │ ├── c.js
│ │ │ └── minor.js
│ │ ├── b.js
│ │ ├── built/
│ │ │ ├── mapConfig-tests.js
│ │ │ ├── mapConfigBuilt.html
│ │ │ ├── mapConfigPlugin-tests.js
│ │ │ ├── mapConfigPluginBuilt.html
│ │ │ ├── mapConfigStar-tests.js
│ │ │ ├── mapConfigStarAdapter-tests.js
│ │ │ ├── mapConfigStarAdapterBuilt.html
│ │ │ └── mapConfigStarBuilt.html
│ │ ├── c/
│ │ │ └── sub.js
│ │ ├── c.js
│ │ ├── c1/
│ │ │ └── sub.js
│ │ ├── c1.js
│ │ ├── c2/
│ │ │ └── sub.js
│ │ ├── c2.js
│ │ ├── d.js
│ │ ├── e.js
│ │ ├── mapConfig-tests.js
│ │ ├── mapConfig.html
│ │ ├── mapConfigDelayed-tests.js
│ │ ├── mapConfigDelayed.html
│ │ ├── mapConfigMulti-tests.js
│ │ ├── mapConfigMulti.html
│ │ ├── mapConfigPlugin-tests.js
│ │ ├── mapConfigPlugin.html
│ │ ├── mapConfigRelative-tests.js
│ │ ├── mapConfigRelative.html
│ │ ├── mapConfigSpecificity-tests.js
│ │ ├── mapConfigSpecificity.html
│ │ ├── mapConfigStar-tests.js
│ │ ├── mapConfigStar.html
│ │ ├── mapConfigStarAdapter-tests.js
│ │ ├── mapConfigStarAdapter.html
│ │ ├── plug/
│ │ │ ├── c1.js
│ │ │ ├── c2.js
│ │ │ └── main.js
│ │ └── plug.js
│ ├── moduleConfig/
│ │ ├── a.js
│ │ ├── b/
│ │ │ └── c.js
│ │ ├── moduleConfig-tests.js
│ │ ├── moduleConfig.html
│ │ └── plain.js
│ ├── moduleExports/
│ │ ├── adder.js
│ │ └── moduleExports.html
│ ├── multiversion.html
│ ├── nestedDefine/
│ │ ├── four.js
│ │ ├── nestedDefine.html
│ │ ├── nestedDefine2.html
│ │ ├── nestedDefine2.js
│ │ ├── one.js
│ │ └── two.js
│ ├── nestedRelativeRequire/
│ │ ├── main.js
│ │ ├── nestedRelativeRequire.html
│ │ └── sub/
│ │ ├── a.js
│ │ └── b.js
│ ├── nestedRequire/
│ │ ├── a.js
│ │ ├── base.js
│ │ ├── nestedRequire-tests.js
│ │ └── nestedRequire.html
│ ├── nestedRequireConfig/
│ │ ├── nestedRequireConfig.html
│ │ └── nestedRequireConfig.js
│ ├── onResourceLoad/
│ │ ├── a.js
│ │ ├── b.js
│ │ ├── nestedRequire-tests.js
│ │ └── nestedRequire.html
│ ├── one.js
│ ├── packages/
│ │ ├── bar/
│ │ │ └── 0.4/
│ │ │ └── scripts/
│ │ │ └── main.js
│ │ ├── baz/
│ │ │ └── lib/
│ │ │ ├── helper.js
│ │ │ └── index.js
│ │ ├── config/
│ │ │ ├── config.html
│ │ │ └── pixie/
│ │ │ └── index.js
│ │ ├── dojox/
│ │ │ ├── door.js
│ │ │ └── window/
│ │ │ ├── pane.js
│ │ │ └── window.js
│ │ ├── foo/
│ │ │ └── lib/
│ │ │ ├── main.js
│ │ │ └── second.js
│ │ ├── funky/
│ │ │ ├── index.js
│ │ │ └── lib/
│ │ │ └── monkey.js
│ │ ├── optimizing/
│ │ │ ├── build.js
│ │ │ ├── main.js
│ │ │ ├── optimizing-built.html
│ │ │ ├── optimizing.html
│ │ │ └── packages/
│ │ │ ├── engine/
│ │ │ │ ├── main.js
│ │ │ │ ├── pistons.js
│ │ │ │ └── sparkplugs.js
│ │ │ ├── fuel/
│ │ │ │ └── main.js
│ │ │ └── tires/
│ │ │ └── main.js
│ │ ├── packages-tests.js
│ │ ├── packages.html
│ │ ├── pkgs/
│ │ │ ├── alpha/
│ │ │ │ ├── main.js
│ │ │ │ └── replace.js
│ │ │ ├── beta/
│ │ │ │ └── 0.2/
│ │ │ │ └── scripts/
│ │ │ │ ├── beta.js
│ │ │ │ └── util.js
│ │ │ └── dojox/
│ │ │ ├── chair/
│ │ │ │ ├── legs.js
│ │ │ │ └── main.js
│ │ │ └── table/
│ │ │ ├── legs.js
│ │ │ └── table.js
│ │ └── replace.js
│ ├── packagesMultiLevel/
│ │ ├── @foo/
│ │ │ └── bar@1.0.0/
│ │ │ ├── index.js
│ │ │ └── other.js
│ │ ├── baz@2.0.0/
│ │ │ ├── helper.js
│ │ │ └── index.js
│ │ ├── build.js
│ │ ├── config.js
│ │ ├── expected-built.js
│ │ ├── packagesMultiLevel-built.html
│ │ ├── packagesMultiLevel-tests-built.js
│ │ ├── packagesMultiLevel-tests.js
│ │ └── packagesMultiLevel.html
│ ├── packagesNestedMain/
│ │ ├── foo/
│ │ │ └── lib/
│ │ │ ├── bar.js
│ │ │ └── index.js
│ │ ├── packagesNestedMain-tests.js
│ │ └── packagesNestedMain.html
│ ├── packagesNode/
│ │ ├── packagesNode-tests.js
│ │ └── packagesNode.html
│ ├── packagesNodeAdapter/
│ │ ├── packagesNodeAdapter-tests.js
│ │ └── packagesNodeAdapter.html
│ ├── pathArray/
│ │ ├── pathArray.html
│ │ ├── pathArrayFail.html
│ │ ├── real.js
│ │ └── withMap/
│ │ ├── dep-private.js
│ │ ├── real.js
│ │ └── withMap.html
│ ├── paths/
│ │ ├── first.js/
│ │ │ ├── first.js
│ │ │ └── second.js
│ │ ├── impl/
│ │ │ ├── array.js
│ │ │ └── util.js
│ │ ├── paths.html
│ │ ├── relativeModuleId-tests.js
│ │ ├── relativeModuleId.html
│ │ ├── relativeNormalize/
│ │ │ ├── bar/
│ │ │ │ └── baz.js
│ │ │ ├── foo2.js
│ │ │ ├── relativeNormalize-tests.js
│ │ │ └── relativeNormalize.html
│ │ └── util.js
│ ├── pluginNormalize/
│ │ └── pluginNormalize.html
│ ├── pluginNormalizeLoad/
│ │ ├── Plugin.js
│ │ └── pluginNormalizeLoad.html
│ ├── plugins/
│ │ ├── a.js
│ │ ├── b.js
│ │ ├── c.js
│ │ ├── complexNormalize/
│ │ │ ├── complexNormalize.html
│ │ │ ├── main.js
│ │ │ └── sub/
│ │ │ ├── modA1.js
│ │ │ ├── modA2.js
│ │ │ ├── plugin.js
│ │ │ └── pluginDep.js
│ │ ├── delegated/
│ │ │ ├── a.refine
│ │ │ ├── delegated-tests.js
│ │ │ ├── delegated.html
│ │ │ └── delegated.js
│ │ ├── double.html
│ │ ├── double.js
│ │ ├── earth.js
│ │ ├── fromText/
│ │ │ ├── a.refine
│ │ │ ├── b.refine
│ │ │ ├── fromText-tests.js
│ │ │ ├── fromText.html
│ │ │ ├── fromTextConfig-tests.js
│ │ │ ├── fromTextConfig.html
│ │ │ └── refine.js
│ │ ├── fromTextEvalError/
│ │ │ ├── a.refine
│ │ │ ├── b.refine
│ │ │ ├── fromTextEvalError-tests.js
│ │ │ └── fromTextEvalError.html
│ │ ├── fromTextNoDefine/
│ │ │ ├── a.refine
│ │ │ ├── fromTextNoDefine-tests.js
│ │ │ ├── fromTextNoDefine.html
│ │ │ └── refine.js
│ │ ├── index.js
│ │ ├── indexBuilder.js
│ │ ├── nameOnly-tests.js
│ │ ├── nameOnly.html
│ │ ├── nameOnly.js
│ │ ├── onerror/
│ │ │ ├── onerror-tests.js
│ │ │ ├── onerror.html
│ │ │ └── thrower.js
│ │ ├── pluginBundles/
│ │ │ ├── main.js
│ │ │ ├── pluginBundles-tests.js
│ │ │ └── pluginBundles.html
│ │ ├── pluginBundlesSeparateText/
│ │ │ ├── main.js
│ │ │ ├── pluginBundlesSeparateText-tests.js
│ │ │ ├── pluginBundlesSeparateText.html
│ │ │ └── second.html
│ │ ├── pluginLast/
│ │ │ ├── app.js
│ │ │ ├── bigCollection.html
│ │ │ ├── bigCollection.js
│ │ │ ├── collection.js
│ │ │ ├── collectionHelper.js
│ │ │ ├── common.js
│ │ │ ├── component.html
│ │ │ ├── component.js
│ │ │ ├── main.js
│ │ │ ├── pluginLast.html
│ │ │ ├── specificCollection.html
│ │ │ └── specificCollection.js
│ │ ├── pluginMap/
│ │ │ ├── dynamic/
│ │ │ │ ├── application.js
│ │ │ │ ├── employee.js
│ │ │ │ ├── main.js
│ │ │ │ ├── person.js
│ │ │ │ ├── plugin.js
│ │ │ │ └── pluginMapDynamic.html
│ │ │ ├── pluginMap-tests.js
│ │ │ └── pluginMap.html
│ │ ├── pluginMapSameName/
│ │ │ ├── plugin/
│ │ │ │ └── plugin.js
│ │ │ ├── pluginMapSameName-tests.js
│ │ │ └── pluginMapSameName.html
│ │ ├── pluginNormalize/
│ │ │ ├── modA.js
│ │ │ ├── modB.js
│ │ │ ├── pluginNormalize-tests.js
│ │ │ └── pluginNormalize.html
│ │ ├── pluginShim/
│ │ │ ├── a.refine
│ │ │ ├── legacy.js
│ │ │ ├── pluginShim-tests.js
│ │ │ └── pluginShim.html
│ │ ├── prime/
│ │ │ ├── a.js
│ │ │ ├── b.js
│ │ │ ├── c.js
│ │ │ └── earth.js
│ │ ├── sync-tests.js
│ │ ├── sync.html
│ │ └── textDepend/
│ │ ├── test.txt
│ │ ├── textDepend-tests.js
│ │ ├── textDepend.html
│ │ └── textDepend.js
│ ├── queryPath.html
│ ├── relative/
│ │ ├── foo/
│ │ │ ├── bar/
│ │ │ │ ├── message.txt
│ │ │ │ ├── one.js
│ │ │ │ └── two.js
│ │ │ ├── bar.js
│ │ │ └── three.js
│ │ ├── greek/
│ │ │ ├── alpha.js
│ │ │ └── main.js
│ │ ├── outsideBaseUrl/
│ │ │ ├── 2.js
│ │ │ ├── a/
│ │ │ │ └── outsideBaseUrl.html
│ │ │ └── b/
│ │ │ ├── 1.js
│ │ │ └── 3.js
│ │ ├── relative-tests.js
│ │ ├── relative.html
│ │ ├── relativeBaseUrl-tests.js
│ │ ├── relativeBaseUrl.html
│ │ └── top.js
│ ├── remoteUrls/
│ │ ├── jqwrap.js
│ │ ├── remoteUrls-tests.js
│ │ ├── remoteUrls.html
│ │ ├── util.js
│ │ └── util2.js
│ ├── requireAsync/
│ │ ├── requireAsync-tests.js
│ │ └── requireAsync.html
│ ├── requirePluginLoad/
│ │ ├── requirePluginLoad-tests.js
│ │ └── requirePluginLoad.html
│ ├── secondLateConfigPlugin/
│ │ ├── app/
│ │ │ └── lib_/
│ │ │ ├── amd/
│ │ │ │ ├── nonamd.js
│ │ │ │ └── text.js
│ │ │ ├── jquery.foo.js
│ │ │ └── jquery.js
│ │ ├── plugin1_ko/
│ │ │ ├── A.js
│ │ │ └── jquery.bar.js
│ │ └── secondLateConfigPlugin.html
│ ├── setTimeout-tests.js
│ ├── setTimeout.html
│ ├── shim/
│ │ ├── a.js
│ │ ├── b.js
│ │ ├── basic-tests.js
│ │ ├── basic.html
│ │ ├── built/
│ │ │ ├── basic-built.html
│ │ │ └── basic-tests.js
│ │ ├── c.js
│ │ ├── d.js
│ │ ├── e.js
│ │ └── f.js
│ ├── simple-badbase.html
│ ├── simple-nohead.html
│ ├── simple-tests.js
│ ├── simple.html
│ ├── simple.js
│ ├── specialDeps/
│ │ ├── foo.js
│ │ ├── specialDeps-tests.js
│ │ └── specialDeps.html
│ ├── text/
│ │ ├── local.js
│ │ ├── plain.txt
│ │ ├── resources/
│ │ │ ├── local.html
│ │ │ └── sample.html
│ │ ├── separate.js
│ │ ├── subwidget.html
│ │ ├── subwidget.js
│ │ ├── subwidget2.html
│ │ ├── text.html
│ │ ├── textBuilt.html
│ │ ├── textBuilt.js
│ │ ├── textOnError.html
│ │ ├── textOnXhr.html
│ │ ├── textOnly.html
│ │ ├── widget.html
│ │ └── widget.js
│ ├── toUrl/
│ │ ├── .hidden.html
│ │ ├── auxil.html
│ │ ├── main.html
│ │ ├── main.js
│ │ ├── sub/
│ │ │ ├── nested/
│ │ │ │ └── thing.js
│ │ │ ├── noext
│ │ │ ├── util.html
│ │ │ └── util.js
│ │ ├── toUrl-tests.js
│ │ └── toUrl.html
│ ├── trailingComma/
│ │ ├── a.js
│ │ ├── trailingComma.html
│ │ └── trailingComma.js
│ ├── tres.js
│ ├── two.js
│ ├── undef/
│ │ ├── globalFoo.js
│ │ ├── real.js
│ │ ├── undef.html
│ │ ├── undefEnforceShim.html
│ │ ├── undefLocal.html
│ │ ├── undefNoRequire.html
│ │ └── undefNoRequire2.html
│ ├── uniques/
│ │ ├── one.js
│ │ ├── three.js
│ │ ├── two.js
│ │ └── uniques.html
│ ├── universal/
│ │ ├── eye.js
│ │ ├── newt.js
│ │ ├── spell.js
│ │ ├── tail.js
│ │ ├── universal-built.html
│ │ ├── universal-tests-built-expected.js
│ │ ├── universal-tests-built.js
│ │ ├── universal-tests.js
│ │ └── universal.html
│ ├── uno.js
│ ├── unorderedDefine/
│ │ ├── app.js
│ │ ├── bar.js
│ │ └── unorderedDefine.html
│ ├── urlArgsBlob.html
│ ├── urlArgsToUrl.html
│ ├── urlArgsToUrlFunction.html
│ ├── urlfetch/
│ │ ├── one.js
│ │ ├── three.js
│ │ ├── two.js
│ │ └── urlfetch.html
│ ├── version1/
│ │ ├── alpha.js
│ │ ├── beta.js
│ │ ├── gamma.js
│ │ └── omega.js
│ ├── version2/
│ │ ├── alpha.js
│ │ ├── beta.js
│ │ ├── epsilon.js
│ │ └── omega.js
│ ├── workers.html
│ └── workers.js
└── updatesubs.sh
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/CONTRIBUTING.md
================================================
# Contributing to requirejs
[See the requirejs.org contributing page](https://requirejs.org/docs/contributing.html).
If you have a question about a specific setup or using particular libraries or file layouts with requirejs, then it is best to ask that on [Stack Overflow using the requirejs tag](https://stackoverflow.com/questions/tagged/requirejs). New issues here are best used for bug reports that have test cases or examples.
================================================
FILE: .gitignore
================================================
.DS_Store
docs/jquery-require-sample/webapp-build/
docs/jquery-require-sample/dist
dist/dist-site/
dist/dist-build/
shrinktest.sh
tests/layers/allplugins-require.js
tests/packages/optimizing/built/
node_modules/
================================================
FILE: .jscsrc
================================================
{
"preset": "google",
"validateIndentation": 4,
"disallowSpacesInAnonymousFunctionExpression": null,
"disallowMultipleVarDecl": null,
"maximumLineLength": {
"value": 120,
"allowComments": true,
"allowRegex": true
},
"excludeFiles": [
"dist/**",
"node_modules/**",
"tests/**"
]
}
================================================
FILE: .jshintrc
================================================
{
"predef": [
"console"
],
"undef": true
}
================================================
FILE: .travis.yml
================================================
sudo: false
language: node_js
node_js:
- 0.12
================================================
FILE: LICENSE
================================================
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/requirejs/requirejs
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
Copyright and related rights for sample code are waived via CC0. Sample
code is defined as all source code displayed within the prose of the
documentation.
CC0: http://creativecommons.org/publicdomain/zero/1.0/
====
Files located in the node_modules directory, and certain utilities used
to build or test the software in the test and dist directories, are
externally maintained libraries used by this software which have their own
licenses; we recommend you read them, as their terms may differ from the
terms above.
================================================
FILE: README.md
================================================
# RequireJS
RequireJS loads plain JavaScript files as well as more defined modules. It is
optimized for in-browser use, including in
[a Web Worker](https://requirejs.org/docs/api.html#webworker), but it can be used
in other JavaScript environments, like Rhino and
[Node](https://requirejs.org/docs/node.html). It implements the
[Asynchronous Module](https://github.com/amdjs/amdjs-api/wiki/AMD)
API.
RequireJS uses plain script tags to load modules/files, so it should allow for
easy debugging. It can be used
[simply to load existing JavaScript files](https://requirejs.org/docs/api.html#jsfiles),
so you can add it to your existing project without having to re-write your
JavaScript files.
RequireJS includes [an optimization tool](https://requirejs.org/docs/optimization.html)
you can run as part of your packaging steps for deploying your code. The
optimization tool can combine and minify your JavaScript files to allow for
better performance.
If the JavaScript file defines a JavaScript module via
[define()](https://requirejs.org/docs/api.html#define), then there are other benefits
RequireJS can offer: [improvements over traditional CommonJS modules](https://requirejs.org/docs/commonjs.html)
and [loading multiple versions](https://requirejs.org/docs/api.html#multiversion)
of a module in a page. RequireJS also has a plugin system that supports features like
[i18n string bundles](https://requirejs.org/docs/api.html#i18n), and
[text file dependencies](https://requirejs.org/docs/api.html#text).
RequireJS does not have any dependencies on a JavaScript framework.
RequireJS works in IE 6+, Firefox 2+, Safari 3.2+, Chrome 3+, and Opera 10+.
[Latest Release](https://requirejs.org/docs/download.html)
## License
MIT
## Code of Conduct
[jQuery Foundation Code of Conduct](https://jquery.org/conduct/).
## Directories
* **dist**: Scripts and assets to generate the requirejs.org docs, and for
generating a require.js release.
* **docs**: The raw HTML files for the requirejs.org docs. Only includes the
body of each page. Files in **dist** are used to generate a complete HTML page.
* **tests**: Tests for require.js.
* **testBaseUrl.js**: A file used in the tests inside **tests**. Purposely
placed outside the tests directory for testing paths that go outside a baseUrl.
* **updatesubs.sh**: Updates projects that depend on require.js Assumes the
projects are siblings to this directory and have specific names. Useful to
copy require.js to dependent projects easily while in development.
## Tests
This repo assumes some other repos are checked out as siblings to this repo:
git clone https://github.com/requirejs/text.git
git clone https://github.com/requirejs/i18n.git
git clone https://github.com/requirejs/domReady.git
git clone https://github.com/requirejs/requirejs.git
So when the above clones are done, the directory structure should look like:
* domReady
* i18n
* text
* requirejs (this repo)
You will need to be connected to the internet because the JSONP and
remoteUrls tests access the internet to complete their tests.
Serve the directory with these 4 siblings from a web server. It can be a local web server.
Open requirejs/tests/index.html in all the browsers, click the arrow button to run all
the tests.
================================================
FILE: dist/Markdown-License.text
================================================
Copyright (c) 2004, John Gruber
<http://daringfireball.net/>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name "Markdown" nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
This software is provided by the copyright holders and contributors "as
is" and any express or implied warranties, including, but not limited
to, the implied warranties of merchantability and fitness for a
particular purpose are disclaimed. In no event shall the copyright owner
or contributors be liable for any direct, indirect, incidental, special,
exemplary, or consequential damages (including, but not limited to,
procurement of substitute goods or services; loss of use, data, or
profits; or business interruption) however caused and on any theory of
liability, whether in contract, strict liability, or tort (including
negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.
================================================
FILE: dist/Markdown.pl
================================================
#!/usr/bin/perl
#
# Markdown -- A text-to-HTML conversion tool for web writers
#
# Copyright (c) 2004 John Gruber
# <http://daringfireball.net/projects/markdown/>
#
package Markdown;
require 5.006_000;
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
use vars qw($VERSION);
$VERSION = '1.0.1';
# Tue 14 Dec 2004
## Disabled; causes problems under Perl 5.6.1:
# use utf8;
# binmode( STDOUT, ":utf8" ); # c.f.: http://acis.openlib.org/dev/perl-unicode-struggle.html
#
# Global default settings:
#
my $g_empty_element_suffix = " />"; # Change to ">" for HTML output
my $g_tab_width = 4;
#
# Globals:
#
# Regex to match balanced [brackets]. See Friedl's
# "Mastering Regular Expressions", 2nd Ed., pp. 328-331.
my $g_nested_brackets;
$g_nested_brackets = qr{
(?> # Atomic matching
[^\[\]]+ # Anything other than brackets
|
\[
(??{ $g_nested_brackets }) # Recursive set of nested brackets
\]
)*
}x;
# Table of hash values for escaped characters:
my %g_escape_table;
foreach my $char (split //, '\\`*_{}[]()>#+-.!') {
$g_escape_table{$char} = md5_hex($char);
}
# Global hashes, used by various utility routines
my %g_urls;
my %g_titles;
my %g_html_blocks;
# Used to track when we're inside an ordered or unordered list
# (see _ProcessListItems() for details):
my $g_list_level = 0;
#### Blosxom plug-in interface ##########################################
# Set $g_blosxom_use_meta to 1 to use Blosxom's meta plug-in to determine
# which posts Markdown should process, using a "meta-markup: markdown"
# header. If it's set to 0 (the default), Markdown will process all
# entries.
my $g_blosxom_use_meta = 0;
sub start { 1; }
sub story {
my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
if ( (! $g_blosxom_use_meta) or
(defined($meta::markup) and ($meta::markup =~ /^\s*markdown\s*$/i))
){
$$body_ref = Markdown($$body_ref);
}
1;
}
#### Movable Type plug-in interface #####################################
eval {require MT}; # Test to see if we're running in MT.
unless ($@) {
require MT;
import MT;
require MT::Template::Context;
import MT::Template::Context;
eval {require MT::Plugin}; # Test to see if we're running >= MT 3.0.
unless ($@) {
require MT::Plugin;
import MT::Plugin;
my $plugin = new MT::Plugin({
name => "Markdown",
description => "A plain-text-to-HTML formatting plugin. (Version: $VERSION)",
doc_link => 'http://daringfireball.net/projects/markdown/'
});
MT->add_plugin( $plugin );
}
MT::Template::Context->add_container_tag(MarkdownOptions => sub {
my $ctx = shift;
my $args = shift;
my $builder = $ctx->stash('builder');
my $tokens = $ctx->stash('tokens');
if (defined ($args->{'output'}) ) {
$ctx->stash('markdown_output', lc $args->{'output'});
}
defined (my $str = $builder->build($ctx, $tokens) )
or return $ctx->error($builder->errstr);
$str; # return value
});
MT->add_text_filter('markdown' => {
label => 'Markdown',
docs => 'http://daringfireball.net/projects/markdown/',
on_format => sub {
my $text = shift;
my $ctx = shift;
my $raw = 0;
if (defined $ctx) {
my $output = $ctx->stash('markdown_output');
if (defined $output && $output =~ m/^html/i) {
$g_empty_element_suffix = ">";
$ctx->stash('markdown_output', '');
}
elsif (defined $output && $output eq 'raw') {
$raw = 1;
$ctx->stash('markdown_output', '');
}
else {
$raw = 0;
$g_empty_element_suffix = " />";
}
}
$text = $raw ? $text : Markdown($text);
$text;
},
});
# If SmartyPants is loaded, add a combo Markdown/SmartyPants text filter:
my $smartypants;
{
no warnings "once";
$smartypants = $MT::Template::Context::Global_filters{'smarty_pants'};
}
if ($smartypants) {
MT->add_text_filter('markdown_with_smartypants' => {
label => 'Markdown With SmartyPants',
docs => 'http://daringfireball.net/projects/markdown/',
on_format => sub {
my $text = shift;
my $ctx = shift;
if (defined $ctx) {
my $output = $ctx->stash('markdown_output');
if (defined $output && $output eq 'html') {
$g_empty_element_suffix = ">";
}
else {
$g_empty_element_suffix = " />";
}
}
$text = Markdown($text);
$text = $smartypants->($text, '1');
},
});
}
}
else {
#### BBEdit/command-line text filter interface ##########################
# Needs to be hidden from MT (and Blosxom when running in static mode).
# We're only using $blosxom::version once; tell Perl not to warn us:
no warnings 'once';
unless ( defined($blosxom::version) ) {
use warnings;
#### Check for command-line switches: #################
my %cli_opts;
use Getopt::Long;
Getopt::Long::Configure('pass_through');
GetOptions(\%cli_opts,
'version',
'shortversion',
'html4tags',
);
if ($cli_opts{'version'}) { # Version info
print "\nThis is Markdown, version $VERSION.\n";
print "Copyright 2004 John Gruber\n";
print "http://daringfireball.net/projects/markdown/\n\n";
exit 0;
}
if ($cli_opts{'shortversion'}) { # Just the version number string.
print $VERSION;
exit 0;
}
if ($cli_opts{'html4tags'}) { # Use HTML tag style instead of XHTML
$g_empty_element_suffix = ">";
}
#### Process incoming text: ###########################
my $text;
{
local $/; # Slurp the whole file
$text = <>;
}
print Markdown($text);
}
}
sub Markdown {
#
# Main function. The order in which other subs are called here is
# essential. Link and image substitutions need to happen before
# _EscapeSpecialChars(), so that any *'s or _'s in the <a>
# and <img> tags get encoded.
#
my $text = shift;
# Clear the global hashes. If we don't clear these, you get conflicts
# from other articles when generating a page which contains more than
# one article (e.g. an index page that shows the N most recent
# articles):
%g_urls = ();
%g_titles = ();
%g_html_blocks = ();
# Standardize line endings:
$text =~ s{\r\n}{\n}g; # DOS to Unix
$text =~ s{\r}{\n}g; # Mac to Unix
# Make sure $text ends with a couple of newlines:
$text .= "\n\n";
# Convert all tabs to spaces.
$text = _Detab($text);
# Strip any lines consisting only of spaces and tabs.
# This makes subsequent regexen easier to write, because we can
# match consecutive blank lines with /\n+/ instead of something
# contorted like /[ \t]*\n+/ .
$text =~ s/^[ \t]+$//mg;
# Turn block-level HTML blocks into hash entries
$text = _HashHTMLBlocks($text);
# Strip link definitions, store in hashes.
$text = _StripLinkDefinitions($text);
$text = _RunBlockGamut($text);
$text = _UnescapeSpecialChars($text);
return $text . "\n";
}
sub _StripLinkDefinitions {
#
# Strips link definitions from text, stores the URLs and titles in
# hash references.
#
my $text = shift;
my $less_than_tab = $g_tab_width - 1;
# Link defs are in the form: ^[id]: url "optional title"
while ($text =~ s{
^[ ]{0,$less_than_tab}\[(.+)\]: # id = $1
[ \t]*
\n? # maybe *one* newline
[ \t]*
<?(\S+?)>? # url = $2
[ \t]*
\n? # maybe one newline
[ \t]*
(?:
(?<=\s) # lookbehind for whitespace
["(]
(.+?) # title = $3
[")]
[ \t]*
)? # title is optional
(?:\n+|\Z)
}
{}mx) {
$g_urls{lc $1} = _EncodeAmpsAndAngles( $2 ); # Link IDs are case-insensitive
if ($3) {
$g_titles{lc $1} = $3;
$g_titles{lc $1} =~ s/"/"/g;
}
}
return $text;
}
sub _HashHTMLBlocks {
my $text = shift;
my $less_than_tab = $g_tab_width - 1;
# Hashify HTML blocks:
# We only want to do this for block-level HTML tags, such as headers,
# lists, and tables. That's because we still want to wrap <p>s around
# "paragraphs" that are wrapped in non-block-level tags, such as anchors,
# phrase emphasis, and spans. The list of tags we're looking for is
# hard-coded:
my $block_tags_a = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del/;
my $block_tags_b = qr/p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math/;
# First, look for nested blocks, e.g.:
# <div>
# <div>
# tags for inner block must be indented.
# </div>
# </div>
#
# The outermost tags must start at the left margin for this to match, and
# the inner nested divs must be indented.
# We need to do this before the next, more liberal match, because the next
# match will start at the first `<div>` and stop at the first `</div>`.
$text =~ s{
( # save in $1
^ # start of line (with /m)
<($block_tags_a) # start tag = $2
\b # word break
(.*\n)*? # any number of lines, minimally matching
</\2> # the matching end tag
[ \t]* # trailing spaces/tabs
(?=\n+|\Z) # followed by a newline or end of document
)
}{
my $key = md5_hex($1);
$g_html_blocks{$key} = $1;
"\n\n" . $key . "\n\n";
}egmx;
#
# Now match more liberally, simply from `\n<tag>` to `</tag>\n`
#
$text =~ s{
( # save in $1
^ # start of line (with /m)
<($block_tags_b) # start tag = $2
\b # word break
(.*\n)*? # any number of lines, minimally matching
.*</\2> # the matching end tag
[ \t]* # trailing spaces/tabs
(?=\n+|\Z) # followed by a newline or end of document
)
}{
my $key = md5_hex($1);
$g_html_blocks{$key} = $1;
"\n\n" . $key . "\n\n";
}egmx;
# Special case just for <hr />. It was easier to make a special case than
# to make the other regex more complicated.
$text =~ s{
(?:
(?<=\n\n) # Starting after a blank line
| # or
\A\n? # the beginning of the doc
)
( # save in $1
[ ]{0,$less_than_tab}
<(hr) # start tag = $2
\b # word break
([^<>])*? #
/?> # the matching end tag
[ \t]*
(?=\n{2,}|\Z) # followed by a blank line or end of document
)
}{
my $key = md5_hex($1);
$g_html_blocks{$key} = $1;
"\n\n" . $key . "\n\n";
}egx;
# Special case for standalone HTML comments:
$text =~ s{
(?:
(?<=\n\n) # Starting after a blank line
| # or
\A\n? # the beginning of the doc
)
( # save in $1
[ ]{0,$less_than_tab}
(?s:
<!
(--.*?--\s*)+
>
)
[ \t]*
(?=\n{2,}|\Z) # followed by a blank line or end of document
)
}{
my $key = md5_hex($1);
$g_html_blocks{$key} = $1;
"\n\n" . $key . "\n\n";
}egx;
return $text;
}
sub _RunBlockGamut {
#
# These are all the transformations that form block-level
# tags like paragraphs, headers, and list items.
#
my $text = shift;
$text = _DoHeaders($text);
# Do Horizontal Rules:
$text =~ s{^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$}{\n<hr$g_empty_element_suffix\n}gmx;
$text =~ s{^[ ]{0,2}([ ]? -[ ]?){3,}[ \t]*$}{\n<hr$g_empty_element_suffix\n}gmx;
$text =~ s{^[ ]{0,2}([ ]? _[ ]?){3,}[ \t]*$}{\n<hr$g_empty_element_suffix\n}gmx;
$text = _DoLists($text);
$text = _DoCodeBlocks($text);
$text = _DoBlockQuotes($text);
# We already ran _HashHTMLBlocks() before, in Markdown(), but that
# was to escape raw HTML in the original Markdown source. This time,
# we're escaping the markup we've just created, so that we don't wrap
# <p> tags around block-level tags.
$text = _HashHTMLBlocks($text);
$text = _FormParagraphs($text);
return $text;
}
sub _RunSpanGamut {
#
# These are all the transformations that occur *within* block-level
# tags like paragraphs, headers, and list items.
#
my $text = shift;
$text = _DoCodeSpans($text);
$text = _EscapeSpecialChars($text);
# Process anchor and image tags. Images must come first,
# because ![foo][f] looks like an anchor.
$text = _DoImages($text);
$text = _DoAnchors($text);
# Make links out of things like `<http://example.com/>`
# Must come after _DoAnchors(), because you can use < and >
# delimiters in inline links like [this](<url>).
$text = _DoAutoLinks($text);
$text = _EncodeAmpsAndAngles($text);
$text = _DoItalicsAndBold($text);
# Do hard breaks:
$text =~ s/ {2,}\n/ <br$g_empty_element_suffix\n/g;
return $text;
}
sub _EscapeSpecialChars {
my $text = shift;
my $tokens ||= _TokenizeHTML($text);
$text = ''; # rebuild $text from the tokens
# my $in_pre = 0; # Keep track of when we're inside <pre> or <code> tags.
# my $tags_to_skip = qr!<(/?)(?:pre|code|kbd|script|math)[\s>]!;
foreach my $cur_token (@$tokens) {
if ($cur_token->[0] eq "tag") {
# Within tags, encode * and _ so they don't conflict
# with their use in Markdown for italics and strong.
# We're replacing each such character with its
# corresponding MD5 checksum value; this is likely
# overkill, but it should prevent us from colliding
# with the escape values by accident.
$cur_token->[1] =~ s! \* !$g_escape_table{'*'}!gx;
$cur_token->[1] =~ s! _ !$g_escape_table{'_'}!gx;
$text .= $cur_token->[1];
} else {
my $t = $cur_token->[1];
$t = _EncodeBackslashEscapes($t);
$text .= $t;
}
}
return $text;
}
sub _DoAnchors {
#
# Turn Markdown link shortcuts into XHTML <a> tags.
#
my $text = shift;
#
# First, handle reference-style links: [link text] [id]
#
$text =~ s{
( # wrap whole match in $1
\[
($g_nested_brackets) # link text = $2
\]
[ ]? # one optional space
(?:\n[ ]*)? # one optional newline followed by spaces
\[
(.*?) # id = $3
\]
)
}{
my $result;
my $whole_match = $1;
my $link_text = $2;
my $link_id = lc $3;
if ($link_id eq "") {
$link_id = lc $link_text; # for shortcut links like [this][].
}
if (defined $g_urls{$link_id}) {
my $url = $g_urls{$link_id};
$url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid
$url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold.
$result = "<a href=\"$url\"";
if ( defined $g_titles{$link_id} ) {
my $title = $g_titles{$link_id};
$title =~ s! \* !$g_escape_table{'*'}!gx;
$title =~ s! _ !$g_escape_table{'_'}!gx;
$result .= " title=\"$title\"";
}
$result .= ">$link_text</a>";
}
else {
$result = $whole_match;
}
$result;
}xsge;
#
# Next, inline-style links: [link text](url "optional title")
#
$text =~ s{
( # wrap whole match in $1
\[
($g_nested_brackets) # link text = $2
\]
\( # literal paren
[ \t]*
<?(.*?)>? # href = $3
[ \t]*
( # $4
(['"]) # quote char = $5
(.*?) # Title = $6
\5 # matching quote
)? # title is optional
\)
)
}{
my $result;
my $whole_match = $1;
my $link_text = $2;
my $url = $3;
my $title = $6;
$url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid
$url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold.
$result = "<a href=\"$url\"";
if (defined $title) {
$title =~ s/"/"/g;
$title =~ s! \* !$g_escape_table{'*'}!gx;
$title =~ s! _ !$g_escape_table{'_'}!gx;
$result .= " title=\"$title\"";
}
$result .= ">$link_text</a>";
$result;
}xsge;
return $text;
}
sub _DoImages {
#
# Turn Markdown image shortcuts into <img> tags.
#
my $text = shift;
#
# First, handle reference-style labeled images: ![alt text][id]
#
$text =~ s{
( # wrap whole match in $1
!\[
(.*?) # alt text = $2
\]
[ ]? # one optional space
(?:\n[ ]*)? # one optional newline followed by spaces
\[
(.*?) # id = $3
\]
)
}{
my $result;
my $whole_match = $1;
my $alt_text = $2;
my $link_id = lc $3;
if ($link_id eq "") {
$link_id = lc $alt_text; # for shortcut links like ![this][].
}
$alt_text =~ s/"/"/g;
if (defined $g_urls{$link_id}) {
my $url = $g_urls{$link_id};
$url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid
$url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold.
$result = "<img src=\"$url\" alt=\"$alt_text\"";
if (defined $g_titles{$link_id}) {
my $title = $g_titles{$link_id};
$title =~ s! \* !$g_escape_table{'*'}!gx;
$title =~ s! _ !$g_escape_table{'_'}!gx;
$result .= " title=\"$title\"";
}
$result .= $g_empty_element_suffix;
}
else {
# If there's no such link ID, leave intact:
$result = $whole_match;
}
$result;
}xsge;
#
# Next, handle inline images: 
# Don't forget: encode * and _
$text =~ s{
( # wrap whole match in $1
!\[
(.*?) # alt text = $2
\]
\( # literal paren
[ \t]*
<?(\S+?)>? # src url = $3
[ \t]*
( # $4
(['"]) # quote char = $5
(.*?) # title = $6
\5 # matching quote
[ \t]*
)? # title is optional
\)
)
}{
my $result;
my $whole_match = $1;
my $alt_text = $2;
my $url = $3;
my $title = '';
if (defined($6)) {
$title = $6;
}
$alt_text =~ s/"/"/g;
$title =~ s/"/"/g;
$url =~ s! \* !$g_escape_table{'*'}!gx; # We've got to encode these to avoid
$url =~ s! _ !$g_escape_table{'_'}!gx; # conflicting with italics/bold.
$result = "<img src=\"$url\" alt=\"$alt_text\"";
if (defined $title) {
$title =~ s! \* !$g_escape_table{'*'}!gx;
$title =~ s! _ !$g_escape_table{'_'}!gx;
$result .= " title=\"$title\"";
}
$result .= $g_empty_element_suffix;
$result;
}xsge;
return $text;
}
sub _DoHeaders {
my $text = shift;
# Setext-style headers:
# Header 1
# ========
#
# Header 2
# --------
#
$text =~ s{ ^(.+)[ \t]*\n=+[ \t]*\n+ }{
"<h1>" . _RunSpanGamut($1) . "</h1>\n\n";
}egmx;
$text =~ s{ ^(.+)[ \t]*\n-+[ \t]*\n+ }{
"<h2>" . _RunSpanGamut($1) . "</h2>\n\n";
}egmx;
# atx-style headers:
# # Header 1
# ## Header 2
# ## Header 2 with closing hashes ##
# ...
# ###### Header 6
#
$text =~ s{
^(\#{1,6}) # $1 = string of #'s
[ \t]*
(.+?) # $2 = Header text
[ \t]*
\#* # optional closing #'s (not counted)
\n+
}{
my $h_level = length($1);
"<h$h_level>" . _RunSpanGamut($2) . "</h$h_level>\n\n";
}egmx;
return $text;
}
sub _DoLists {
#
# Form HTML ordered (numbered) and unordered (bulleted) lists.
#
my $text = shift;
my $less_than_tab = $g_tab_width - 1;
# Re-usable patterns to match list item bullets and number markers:
my $marker_ul = qr/[*+-]/;
my $marker_ol = qr/\d+[.]/;
my $marker_any = qr/(?:$marker_ul|$marker_ol)/;
# Re-usable pattern to match any entirel ul or ol list:
my $whole_list = qr{
( # $1 = whole list
( # $2
[ ]{0,$less_than_tab}
(${marker_any}) # $3 = first list item marker
[ \t]+
)
(?s:.+?)
( # $4
\z
|
\n{2,}
(?=\S)
(?! # Negative lookahead for another list item marker
[ \t]*
${marker_any}[ \t]+
)
)
)
}mx;
# We use a different prefix before nested lists than top-level lists.
# See extended comment in _ProcessListItems().
#
# Note: There's a bit of duplication here. My original implementation
# created a scalar regex pattern as the conditional result of the test on
# $g_list_level, and then only ran the $text =~ s{...}{...}egmx
# substitution once, using the scalar as the pattern. This worked,
# everywhere except when running under MT on my hosting account at Pair
# Networks. There, this caused all rebuilds to be killed by the reaper (or
# perhaps they crashed, but that seems incredibly unlikely given that the
# same script on the same server ran fine *except* under MT. I've spent
# more time trying to figure out why this is happening than I'd like to
# admit. My only guess, backed up by the fact that this workaround works,
# is that Perl optimizes the substition when it can figure out that the
# pattern will never change, and when this optimization isn't on, we run
# afoul of the reaper. Thus, the slightly redundant code to that uses two
# static s/// patterns rather than one conditional pattern.
if ($g_list_level) {
$text =~ s{
^
$whole_list
}{
my $list = $1;
my $list_type = ($3 =~ m/$marker_ul/) ? "ul" : "ol";
# Turn double returns into triple returns, so that we can make a
# paragraph for the last item in a list, if necessary:
$list =~ s/\n{2,}/\n\n\n/g;
my $result = _ProcessListItems($list, $marker_any);
$result = "<$list_type>\n" . $result . "</$list_type>\n";
$result;
}egmx;
}
else {
$text =~ s{
(?:(?<=\n\n)|\A\n?)
$whole_list
}{
my $list = $1;
my $list_type = ($3 =~ m/$marker_ul/) ? "ul" : "ol";
# Turn double returns into triple returns, so that we can make a
# paragraph for the last item in a list, if necessary:
$list =~ s/\n{2,}/\n\n\n/g;
my $result = _ProcessListItems($list, $marker_any);
$result = "<$list_type>\n" . $result . "</$list_type>\n";
$result;
}egmx;
}
return $text;
}
sub _ProcessListItems {
#
# Process the contents of a single ordered or unordered list, splitting it
# into individual list items.
#
my $list_str = shift;
my $marker_any = shift;
# The $g_list_level global keeps track of when we're inside a list.
# Each time we enter a list, we increment it; when we leave a list,
# we decrement. If it's zero, we're not in a list anymore.
#
# We do this because when we're not inside a list, we want to treat
# something like this:
#
# I recommend upgrading to version
# 8. Oops, now this line is treated
# as a sub-list.
#
# As a single paragraph, despite the fact that the second line starts
# with a digit-period-space sequence.
#
# Whereas when we're inside a list (or sub-list), that line will be
# treated as the start of a sub-list. What a kludge, huh? This is
# an aspect of Markdown's syntax that's hard to parse perfectly
# without resorting to mind-reading. Perhaps the solution is to
# change the syntax rules such that sub-lists must start with a
# starting cardinal number; e.g. "1." or "a.".
$g_list_level++;
# trim trailing blank lines:
$list_str =~ s/\n{2,}\z/\n/;
$list_str =~ s{
(\n)? # leading line = $1
(^[ \t]*) # leading whitespace = $2
($marker_any) [ \t]+ # list marker = $3
((?s:.+?) # list item text = $4
(\n{1,2}))
(?= \n* (\z | \2 ($marker_any) [ \t]+))
}{
my $item = $4;
my $leading_line = $1;
my $leading_space = $2;
if ($leading_line or ($item =~ m/\n{2,}/)) {
$item = _RunBlockGamut(_Outdent($item));
}
else {
# Recursion for sub-lists:
$item = _DoLists(_Outdent($item));
chomp $item;
$item = _RunSpanGamut($item);
}
"<li>" . $item . "</li>\n";
}egmx;
$g_list_level--;
return $list_str;
}
sub _DoCodeBlocks {
#
# Process Markdown `<pre><code>` blocks.
#
my $text = shift;
$text =~ s{
(?:\n\n|\A)
( # $1 = the code block -- one or more lines, starting with a space/tab
(?:
(?:[ ]{$g_tab_width} | \t) # Lines must start with a tab or a tab-width of spaces
.*\n+
)+
)
((?=^[ ]{0,$g_tab_width}\S)|\Z) # Lookahead for non-space at line-start, or end of doc
}{
my $codeblock = $1;
my $result; # return value
$codeblock = _EncodeCode(_Outdent($codeblock));
$codeblock = _Detab($codeblock);
$codeblock =~ s/\A\n+//; # trim leading newlines
$codeblock =~ s/\s+\z//; # trim trailing whitespace
$result = "\n\n<pre><code>" . $codeblock . "\n</code></pre>\n\n";
$result;
}egmx;
return $text;
}
sub _DoCodeSpans {
#
# * Backtick quotes are used for <code></code> spans.
#
# * You can use multiple backticks as the delimiters if you want to
# include literal backticks in the code span. So, this input:
#
# Just type ``foo `bar` baz`` at the prompt.
#
# Will translate to:
#
# <p>Just type <code>foo `bar` baz</code> at the prompt.</p>
#
# There's no arbitrary limit to the number of backticks you
# can use as delimters. If you need three consecutive backticks
# in your code, use four for delimiters, etc.
#
# * You can use spaces to get literal backticks at the edges:
#
# ... type `` `bar` `` ...
#
# Turns to:
#
# ... type <code>`bar`</code> ...
#
my $text = shift;
$text =~ s@
(`+) # $1 = Opening run of `
(.+?) # $2 = The code block
(?<!`)
\1 # Matching closer
(?!`)
@
my $c = "$2";
$c =~ s/^[ \t]*//g; # leading whitespace
$c =~ s/[ \t]*$//g; # trailing whitespace
$c = _EncodeCode($c);
"<code>$c</code>";
@egsx;
return $text;
}
sub _EncodeCode {
#
# Encode/escape certain characters inside Markdown code runs.
# The point is that in code, these characters are literals,
# and lose their special Markdown meanings.
#
local $_ = shift;
# Encode all ampersands; HTML entities are not
# entities within a Markdown code span.
s/&/&/g;
# Encode $'s, but only if we're running under Blosxom.
# (Blosxom interpolates Perl variables in article bodies.)
{
no warnings 'once';
if (defined($blosxom::version)) {
s/\$/$/g;
}
}
# Do the angle bracket song and dance:
s! < !<!gx;
s! > !>!gx;
# Now, escape characters that are magic in Markdown:
s! \* !$g_escape_table{'*'}!gx;
s! _ !$g_escape_table{'_'}!gx;
s! { !$g_escape_table{'{'}!gx;
s! } !$g_escape_table{'}'}!gx;
s! \[ !$g_escape_table{'['}!gx;
s! \] !$g_escape_table{']'}!gx;
s! \\ !$g_escape_table{'\\'}!gx;
return $_;
}
sub _DoItalicsAndBold {
my $text = shift;
# <strong> must go first:
$text =~ s{ (\*\*|__) (?=\S) (.+?[*_]*) (?<=\S) \1 }
{<strong>$2</strong>}gsx;
$text =~ s{ (\*|_) (?=\S) (.+?) (?<=\S) \1 }
{<em>$2</em>}gsx;
return $text;
}
sub _DoBlockQuotes {
my $text = shift;
$text =~ s{
( # Wrap whole match in $1
(
^[ \t]*>[ \t]? # '>' at the start of a line
.+\n # rest of the first line
(.+\n)* # subsequent consecutive lines
\n* # blanks
)+
)
}{
my $bq = $1;
$bq =~ s/^[ \t]*>[ \t]?//gm; # trim one level of quoting
$bq =~ s/^[ \t]+$//mg; # trim whitespace-only lines
$bq = _RunBlockGamut($bq); # recurse
$bq =~ s/^/ /g;
# These leading spaces screw with <pre> content, so we need to fix that:
$bq =~ s{
(\s*<pre>.+?</pre>)
}{
my $pre = $1;
$pre =~ s/^ //mg;
$pre;
}egsx;
"<blockquote>\n$bq\n</blockquote>\n\n";
}egmx;
return $text;
}
sub _FormParagraphs {
#
# Params:
# $text - string to process with html <p> tags
#
my $text = shift;
# Strip leading and trailing lines:
$text =~ s/\A\n+//;
$text =~ s/\n+\z//;
my @grafs = split(/\n{2,}/, $text);
#
# Wrap <p> tags.
#
foreach (@grafs) {
unless (defined( $g_html_blocks{$_} )) {
$_ = _RunSpanGamut($_);
s/^([ \t]*)/<p>/;
$_ .= "</p>";
}
}
#
# Unhashify HTML blocks
#
foreach (@grafs) {
if (defined( $g_html_blocks{$_} )) {
$_ = $g_html_blocks{$_};
}
}
return join "\n\n", @grafs;
}
sub _EncodeAmpsAndAngles {
# Smart processing for ampersands and angle brackets that need to be encoded.
my $text = shift;
# Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin:
# http://bumppo.net/projects/amputator/
$text =~ s/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/&/g;
# Encode naked <'s
$text =~ s{<(?![a-z/?\$!])}{<}gi;
return $text;
}
sub _EncodeBackslashEscapes {
#
# Parameter: String.
# Returns: The string, with after processing the following backslash
# escape sequences.
#
local $_ = shift;
s! \\\\ !$g_escape_table{'\\'}!gx; # Must process escaped backslashes first.
s! \\` !$g_escape_table{'`'}!gx;
s! \\\* !$g_escape_table{'*'}!gx;
s! \\_ !$g_escape_table{'_'}!gx;
s! \\\{ !$g_escape_table{'{'}!gx;
s! \\\} !$g_escape_table{'}'}!gx;
s! \\\[ !$g_escape_table{'['}!gx;
s! \\\] !$g_escape_table{']'}!gx;
s! \\\( !$g_escape_table{'('}!gx;
s! \\\) !$g_escape_table{')'}!gx;
s! \\> !$g_escape_table{'>'}!gx;
s! \\\# !$g_escape_table{'#'}!gx;
s! \\\+ !$g_escape_table{'+'}!gx;
s! \\\- !$g_escape_table{'-'}!gx;
s! \\\. !$g_escape_table{'.'}!gx;
s{ \\! }{$g_escape_table{'!'}}gx;
return $_;
}
sub _DoAutoLinks {
my $text = shift;
$text =~ s{<((https?|ftp):[^'">\s]+)>}{<a href="$1">$1</a>}gi;
# Email addresses: <address@domain.foo>
$text =~ s{
<
(?:mailto:)?
(
[-.\w]+
\@
[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
)
>
}{
_EncodeEmailAddress( _UnescapeSpecialChars($1) );
}egix;
return $text;
}
sub _EncodeEmailAddress {
#
# Input: an email address, e.g. "foo@example.com"
#
# Output: the email address as a mailto link, with each character
# of the address encoded as either a decimal or hex entity, in
# the hopes of foiling most address harvesting spam bots. E.g.:
#
# <a href="mailto:foo@e
# xample.com">foo
# @example.com</a>
#
# Based on a filter by Matthew Wickline, posted to the BBEdit-Talk
# mailing list: <http://tinyurl.com/yu7ue>
#
my $addr = shift;
srand;
my @encode = (
sub { '&#' . ord(shift) . ';' },
sub { '&#x' . sprintf( "%X", ord(shift) ) . ';' },
sub { shift },
);
$addr = "mailto:" . $addr;
$addr =~ s{(.)}{
my $char = $1;
if ( $char eq '@' ) {
# this *must* be encoded. I insist.
$char = $encode[int rand 1]->($char);
} elsif ( $char ne ':' ) {
# leave ':' alone (to spot mailto: later)
my $r = rand;
# roughly 10% raw, 45% hex, 45% dec
$char = (
$r > .9 ? $encode[2]->($char) :
$r < .45 ? $encode[1]->($char) :
$encode[0]->($char)
);
}
$char;
}gex;
$addr = qq{<a href="$addr">$addr</a>};
$addr =~ s{">.+?:}{">}; # strip the mailto: from the visible part
return $addr;
}
sub _UnescapeSpecialChars {
#
# Swap back in all the special characters we've hidden.
#
my $text = shift;
while( my($char, $hash) = each(%g_escape_table) ) {
$text =~ s/$hash/$char/g;
}
return $text;
}
sub _TokenizeHTML {
#
# Parameter: String containing HTML markup.
# Returns: Reference to an array of the tokens comprising the input
# string. Each token is either a tag (possibly with nested,
# tags contained therein, such as <a href="<MTFoo>">, or a
# run of text between tags. Each element of the array is a
# two-element array; the first is either 'tag' or 'text';
# the second is the actual value.
#
#
# Derived from the _tokenize() subroutine from Brad Choate's MTRegex plugin.
# <http://www.bradchoate.com/past/mtregex.php>
#
my $str = shift;
my $pos = 0;
my $len = length $str;
my @tokens;
my $depth = 6;
my $nested_tags = join('|', ('(?:<[a-z/!$](?:[^<>]') x $depth) . (')*>)' x $depth);
my $match = qr/(?s: <! ( -- .*? -- \s* )+ > ) | # comment
(?s: <\? .*? \?> ) | # processing instruction
$nested_tags/ix; # nested tags
while ($str =~ m/($match)/g) {
my $whole_tag = $1;
my $sec_start = pos $str;
my $tag_start = $sec_start - length $whole_tag;
if ($pos < $tag_start) {
push @tokens, ['text', substr($str, $pos, $tag_start - $pos)];
}
push @tokens, ['tag', $whole_tag];
$pos = pos $str;
}
push @tokens, ['text', substr($str, $pos, $len - $pos)] if $pos < $len;
\@tokens;
}
sub _Outdent {
#
# Remove one level of line-leading tabs or spaces
#
my $text = shift;
$text =~ s/^(\t|[ ]{1,$g_tab_width})//gm;
return $text;
}
sub _Detab {
#
# Cribbed from a post by Bart Lateur:
# <http://www.nntp.perl.org/group/perl.macperl.anyperl/154>
#
my $text = shift;
$text =~ s{(.*?)\t}{$1.(' ' x ($g_tab_width - length($1) % $g_tab_width))}ge;
return $text;
}
1;
__END__
=pod
=head1 NAME
B<Markdown>
=head1 SYNOPSIS
B<Markdown.pl> [ B<--html4tags> ] [ B<--version> ] [ B<-shortversion> ]
[ I<file> ... ]
=head1 DESCRIPTION
Markdown is a text-to-HTML filter; it translates an easy-to-read /
easy-to-write structured text format into HTML. Markdown's text format
is most similar to that of plain text email, and supports features such
as headers, *emphasis*, code blocks, blockquotes, and links.
Markdown's syntax is designed not as a generic markup language, but
specifically to serve as a front-end to (X)HTML. You can use span-level
HTML tags anywhere in a Markdown document, and you can use block level
HTML tags (like <div> and <table> as well).
For more information about Markdown's syntax, see:
http://daringfireball.net/projects/markdown/
=head1 OPTIONS
Use "--" to end switch parsing. For example, to open a file named "-z", use:
Markdown.pl -- -z
=over 4
=item B<--html4tags>
Use HTML 4 style for empty element tags, e.g.:
<br>
instead of Markdown's default XHTML style tags, e.g.:
<br />
=item B<-v>, B<--version>
Display Markdown's version number and copyright information.
=item B<-s>, B<--shortversion>
Display the short-form version number.
=back
=head1 BUGS
To file bug reports or feature requests (other than topics listed in the
Caveats section above) please send email to:
support@daringfireball.net
Please include with your report: (1) the example input; (2) the output
you expected; (3) the output Markdown actually produced.
=head1 VERSION HISTORY
See the readme file for detailed release notes for this version.
1.0.1 - 14 Dec 2004
1.0 - 28 Aug 2004
=head1 AUTHOR
John Gruber
http://daringfireball.net
PHP port and other contributions by Michel Fortin
http://michelf.com
=head1 COPYRIGHT AND LICENSE
Copyright (c) 2003-2004 John Gruber
<http://daringfireball.net/>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name "Markdown" nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
This software is provided by the copyright holders and contributors "as
is" and any express or implied warranties, including, but not limited
to, the implied warranties of merchantability and fitness for a
particular purpose are disclaimed. In no event shall the copyright owner
or contributors be liable for any direct, indirect, incidental, special,
exemplary, or consequential damages (including, but not limited to,
procurement of substitute goods or services; loss of use, data, or
profits; or business interruption) however caused and on any theory of
liability, whether in contract, strict liability, or tort (including
negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.
=cut
================================================
FILE: dist/README.md
================================================
# RequireJS dist
This directory contains the tools that are used to build distributions of RequireJS and its web site.
When doing a release, do the following:
* Update files to the new version number:
* require.js, both places
* docs/download.md: check for nested paths too, add new release section
* pre.html
* post.html
* Update version in x.js in the r.js project if necessary.
* ./updatesubs.sh
* Check in changes to r.js project.
* Check in changes to sample projects:
* requirejs/example-jquery-cdn
* requirejs/example-jquery-shim
* requirejs/example-multipage
* requirejs/example-multipage-shim
* requirejs/example-libglobal
* volojs/create-template
* volojs/create-responsive-template
* amodrojs/amodro-trace (UPDATE ESPRIMA(?), parse.js?, run tests too)
* Tag the requirejs and r.js trees:
* git tag -am "Release 0.0.0" 0.0.0
* git push --tags
* UPDATE THE "latest" tags
* Commit changes to cajon, test
* Rev cajon version
* change package.json
* tag it
* npm publish
* Update the requirejs-npm directory
* Update version in package.json
* Modify bin/r.js to add: #!/usr/bin/env node
* npm uninstall -g requirejs
* npm install . -g
* r.js -v
* node (then use repl to do require("requirejs"))
* Try a local install.
* npm publish (in the requirejs-npm/requirejs directory)
* Update requirejs-bower
* tag the repo, with "latest" too.
* git push
* Update the requirejs-nuget directory (DO ON WINDOWS)
* Update the require.js and r.js versions in content/Scripts using `volo add -nostamp -f`
* Update Package.nuspec to rev version number.
* .\nuget.exe pack Package.nuspec
* .\nuget.exe push RequireJS.0.0.0.nupkg API_KEY -Source https://www.nuget.org/api/v2/package
* Update alameda, alameda-prim if appropriate
Now pull down the tagged version to do a distribution, do this in git/ directory:
* rm -rf ./requirejs-dist ./requirejs-build
* git clone git://github.com/requirejs/requirejs.git requirejs-dist
* cd requirejs-dist
* git checkout 0.0.0
* cd dist
Run the distribution tasks.
To generate a build
* ./dist-build.sh 0.0.0
To generate the web site:
* node dist-site.js
* cd dist-site
* zip -r docs.zip ./*
* mv docs.zip ../../../requirejs-build/
================================================
FILE: dist/dist-build.sh
================================================
#!/bin/bash
#version should be something like 0.9.0beta or 0.9.0
version=$1
if [ -z $version ]; then
echo "Please pass in a version number"
exit 1
fi
myDir=`cd \`dirname "$0"\`; pwd`
# First update the sub-projects with the latest.
cd ..
./updatesubs.sh
cd dist
# Setup a build directory
rm -rf ../../requirejs-build
mkdir ../../requirejs-build
# Create the version output dir
cd ../../requirejs-build
mkdir $version
mkdir $version/minified
mkdir $version/comments
# Copy over the r.js file, and set up that project for a dist checkin.
cp ../r.js/r.js $version/r.js
cp ../r.js/r.js ../r.js/dist/r-$version.js
# Copy over basic script deliverables
cp $myDir/../require.js $version/comments/require.js
# Minify any of the browser-based JS files
cd $version/comments
uglifyjs require.js -mc --comments -o ../minified/require.js
cd ../../../
================================================
FILE: dist/dist-site.js
================================================
/*
To run this file:
> node dist-site.js
*/
/*jslint regexp: false, nomen: false, plusplus: false, strict: false */
/*global require: false, console: false */
var files, htmlFile, transFile, fileContents,
preContents, postContents, h1, homePath, cssPath,
ieCssPath, jsPath, length, j, title,
isTopPage = false,
fileIndex = 0,
h1RegExp = /<h1>([^<]+)<\/h1>/,
file = require('./file'),
child_process = require('child_process');
//Copy all the text files to a dist directory
//file.deleteFile("./dist-site/");
file.copyFile("init.js", "./dist-site/init.js");
file.copyDir("fonts", "./dist-site/fonts", /\w/);
file.copyFile("../index.html", "./dist-site/index.html");
file.copyDir("../docs/", "./dist-site/docs/", /\w/);
preContents = file.readFile("pre.html");
postContents = file.readFile("post.html");
//Convert each .html file to a full HTML file
files = file.getFilteredFileList("./dist-site", /\.html$/, true);
function processFile() {
htmlFile = files[fileIndex];
fileIndex += 1;
if (!htmlFile) {
//Done processing files.
return;
}
transFile = htmlFile + '.trans';
console.log("Creating " + htmlFile);
//Do Markdown
child_process.exec(
"./Markdown.pl --html4tags " + htmlFile + " > " + transFile,
function (error, stdout, stderr) {
if (error) {
console.log('Could not markdown ' + htmlFile);
processFile();
return;
}
//Build up a complete HTML file.
fileContents = file.readFile(transFile);
//Find the page title.
title = h1RegExp.exec(fileContents);
title = title && title[1];
fileContents = preContents + fileContents + postContents;
//Set the title of the HTML page
h1 = fileContents.match(/<h1>([^<]+)<\/h1>/);
if (h1 && h1[1]) {
h1 = h1[1];
} else {
h1 = "";
}
fileContents = fileContents.replace(/\$\{title\}/, h1);
//Change any .md references to .html references, and remove tree/master
//links
fileContents = fileContents
.replace(/href="requirejs\/tree\/master\/docs\//g, 'href="docs/')
.replace(/href="([^"]+)\.md/g, 'href="$1.html');
//Adjust the path the home and main.css
homePath = htmlFile.replace(/\/[^\/]+$/, "").replace(/^\.\/dist-site\//, "");
if (!homePath || homePath === "dist-site") {
isTopPage = true;
homePath = "./";
cssPath = "main.css";
ieCssPath = "ie.css";
jsPath = "init.js";
} else {
isTopPage = false;
length = homePath.split("/").length;
homePath = "";
for (j = 0; j < length - 1; j++) {
homePath += "../";
}
cssPath = homePath + "main.css";
ieCssPath = homePath + "ie.css";
jsPath = homePath + "init.js";
}
fileContents = fileContents.replace(/HOMEPATH/g, homePath);
fileContents = fileContents.replace(/\main\.css/, cssPath);
fileContents = fileContents.replace(/\ie\.css/, ieCssPath);
fileContents = fileContents.replace(/\init\.js/, jsPath);
//Set the page title to be the first h1 tag name
if (title) {
fileContents = fileContents.replace(/<title>[^<]*<\/title>/, '<title>' + title + '</title>');
}
//If it is the top page, adjust the header links
if (isTopPage) {
fileContents = fileContents
.replace(/href="\.\.\/"/g, 'href="./"')
.replace(/class="local" href="([^"]+)"/g, 'class="local" href="docs/$1"');
}
file.saveFile(htmlFile, fileContents);
file.deleteFile(transFile);
processFile();
}
);
}
processFile();
================================================
FILE: dist/file.js
================================================
/*jslint plusplus: false, octal:false, strict: false */
/*global require: false, exports: false */
var fs = require('fs'),
path = require('path'),
file, prop;
function mkDir(dir) {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, 0777);
}
}
function mkFullDir(dir) {
var parts = dir.split('/'),
currDir = '',
first = true;
parts.forEach(function (part) {
//First part may be empty string if path starts with a slash.
currDir += part + '/';
first = false;
if (part) {
mkDir(currDir);
}
});
}
file = {
backSlashRegExp: /\\/g,
getLineSeparator: function () {
return '/';
},
exists: function (fileName) {
return fs.existsSync(fileName);
},
parent: function (fileName) {
var parts = fileName.split('/');
parts.pop();
return parts.join('/');
},
/**
* Gets the absolute file path as a string, normalized
* to using front slashes for path separators.
* @param {String} fileName
*/
absPath: function (fileName) {
return path.normalize(fs.realpathSync(fileName).replace(/\\/g, '/'));
},
normalize: function (fileName) {
return path.normalize(fileName);
},
isFile: function (path) {
return fs.statSync(path).isFile();
},
isDirectory: function (path) {
return fs.statSync(path).isDirectory();
},
getFilteredFileList: function (/*String*/startDir, /*RegExp*/regExpFilters, /*boolean?*/makeUnixPaths) {
//summary: Recurses startDir and finds matches to the files that match regExpFilters.include
//and do not match regExpFilters.exclude. Or just one regexp can be passed in for regExpFilters,
//and it will be treated as the "include" case.
//Ignores files/directories that start with a period (.).
var files = [], topDir, regExpInclude, regExpExclude, dirFileArray,
i, stat, filePath, ok, dirFiles, fileName;
topDir = startDir;
regExpInclude = regExpFilters.include || regExpFilters;
regExpExclude = regExpFilters.exclude || null;
if (fs.existsSync(topDir)) {
dirFileArray = fs.readdirSync(topDir);
for (i = 0; i < dirFileArray.length; i++) {
fileName = dirFileArray[i];
filePath = path.join(topDir, fileName);
stat = fs.statSync(filePath);
if (stat.isFile()) {
if (makeUnixPaths) {
//Make sure we have a JS string.
if (filePath.indexOf("/") === -1) {
filePath = filePath.replace(/\\/g, "/");
}
}
ok = true;
if (regExpInclude) {
ok = filePath.match(regExpInclude);
}
if (ok && regExpExclude) {
ok = !filePath.match(regExpExclude);
}
if (ok && !fileName.match(/^\./)) {
files.push(filePath);
}
} else if (stat.isDirectory() && !fileName.match(/^\./)) {
dirFiles = this.getFilteredFileList(filePath, regExpFilters, makeUnixPaths);
files.push.apply(files, dirFiles);
}
}
}
return files; //Array
},
copyDir: function (/*String*/srcDir, /*String*/destDir, /*RegExp?*/regExpFilter, /*boolean?*/onlyCopyNew) {
//summary: copies files from srcDir to destDir using the regExpFilter to determine if the
//file should be copied. Returns a list file name strings of the destinations that were copied.
regExpFilter = regExpFilter || /\w/;
var fileNames = file.getFilteredFileList(srcDir, regExpFilter, true),
copiedFiles = [], i, srcFileName, destFileName;
for (i = 0; i < fileNames.length; i++) {
srcFileName = fileNames[i];
destFileName = srcFileName.replace(srcDir, destDir);
if (file.copyFile(srcFileName, destFileName, onlyCopyNew)) {
copiedFiles.push(destFileName);
}
}
return copiedFiles.length ? copiedFiles : null; //Array or null
},
copyFile: function (/*String*/srcFileName, /*String*/destFileName, /*boolean?*/onlyCopyNew) {
//summary: copies srcFileName to destFileName. If onlyCopyNew is set, it only copies the file if
//srcFileName is newer than destFileName. Returns a boolean indicating if the copy occurred.
var parentDir;
//logger.trace("Src filename: " + srcFileName);
//logger.trace("Dest filename: " + destFileName);
//If onlyCopyNew is true, then compare dates and only copy if the src is newer
//than dest.
if (onlyCopyNew) {
if (fs.existsSync(destFileName) && fs.statSync(destFileName).mtime.getTime() >= fs.statSync(srcFileName).mtime.getTime()) {
return false; //Boolean
}
}
//Make sure destination dir exists.
parentDir = path.dirname(destFileName);
if (!fs.existsSync(parentDir)) {
mkFullDir(parentDir);
}
fs.writeFileSync(destFileName, fs.readFileSync(srcFileName, 'binary'), 'binary');
return true; //Boolean
},
/**
* Reads a *text* file.
*/
readFile: function (/*String*/path, /*String?*/encoding) {
if (encoding === 'utf-8') {
encoding = 'utf8';
}
if (!encoding) {
encoding = 'utf8';
}
return fs.readFileSync(path, encoding);
},
saveUtf8File: function (/*String*/fileName, /*String*/fileContents) {
//summary: saves a *text* file using UTF-8 encoding.
file.saveFile(fileName, fileContents, "utf8");
},
saveFile: function (/*String*/fileName, /*String*/fileContents, /*String?*/encoding) {
//summary: saves a *text* file.
var parentDir;
if (encoding === 'utf-8') {
encoding = 'utf8';
}
if (!encoding) {
encoding = 'utf8';
}
//Make sure destination directories exist.
parentDir = path.dirname(fileName);
if (!fs.existsSync(parentDir)) {
mkFullDir(parentDir);
}
fs.writeFileSync(fileName, fileContents, encoding);
},
deleteFile: function (/*String*/fileName) {
//summary: deletes a file or directory if it exists.
var files, i, stat;
if (fs.existsSync(fileName)) {
stat = fs.statSync(fileName);
if (stat.isDirectory()) {
files = fs.readdirSync(fileName);
for (i = 0; i < files.length; i++) {
this.deleteFile(path.join(fileName, files[i]));
}
fs.rmdirSync(fileName);
} else {
fs.unlinkSync(fileName);
}
}
}
};
for (prop in file) {
if (file.hasOwnProperty(prop)) {
exports[prop] = file[prop];
}
}
================================================
FILE: dist/fonts/PT-Sans/Paratype PT Sans Free Font License.txt
================================================
Copyright © 2009 ParaType Ltd.
with Reserved Names "PT Sans" and "ParaType".
FONT LICENSE
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining a copy of the font software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the font software, subject to the following conditions:
1) Neither the font software nor any of its individual components, in original or modified versions, may be sold by itself.
2) Original or modified versions of the font software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
3) No modified version of the font software may use the Reserved Name(s) or combinations of Reserved Names with other words unless explicit written permission is granted by the ParaType. This restriction only applies to the primary font name as presented to the users.
4) The name of ParaType or the author(s) of the font software shall not be used to promote, endorse or advertise any modified version, except to acknowledge the contribution(s) of ParaType and the author(s) or with explicit written permission of ParaType.
5) The font software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
TERMINATION & TERRITORY
This license has no limits on time and territory, but it becomes null and void if any of the above conditions are not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL PARATYPE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
ParaType Ltd
http://www.paratype.ru
================================================
FILE: dist/init.js
================================================
$(document).ready(function($) {
// set panel min-height to full browser height
$(window).bind("load resize", function(){
var h = $(window).height();
$("#wrapper, #grid, #navBg").css({ "min-height" : (h) });
$("#content").css({ "min-height" : (h-168) });
});
// toggle grid
$("#grid").hide();
$(document.documentElement).keyup(function (event) {
if (event.keyCode == 71) {
$("#grid").fadeToggle(100);
}
});
// if window is larger than #nav then #nav == fixed, if #nav is larger than window #nav == relative
$(window).bind("load resize", function(){
var w = $(window).height();
var h = $("#nav").outerHeight();
$("#nav").css("position",(w < h) ? "" : "fixed");
});
// open / close off-canvas navigation
$('.off-canvas-button').click(function() {
// transform button to close shape
$(this).toggleClass('open');
// slide in side navigation
$('#nav').toggleClass('open');
});
// done!
});
================================================
FILE: dist/post.html
================================================
</div>
<div id="footer" class="mono">
<span class="line">Latest Release: <a href="https://requirejs.org/docs/download.html">2.3.8</a></span>
<span class="line">Code is open source: <a href="https://github.com/requirejs/requirejs/blob/master/LICENSE">new BSD or MIT licensed</a></span>
<span class="line">logo and web design by <a href="http://andychung.me/">Andy Chung</a> <a href="https://github.com/requirejs/requirejs-branding">© 2010-2018</a></span>
</div>
</div>
</body>
</html>
================================================
FILE: dist/pre.html
================================================
<!DOCTYPE html>
<html>
<head>
<title>RequireJS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<link rel="stylesheet" type="text/css" href="main.css">
<link rel="icon" type="image/x-icon" href="/favicon.png">
<!--[if IE]> <link rel="stylesheet" type="text/css" href="ie.css" /> <![endif]-->
<link rel="stylesheet" type="text/css" href="https://ajax.googleapis.com/ajax/libs/dojo/1.4/dojox/highlight/resources/highlight.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="init.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js"></script>
<script type="text/javascript">
dojo.registerModulePath("dojo", "https://ajax.googleapis.com/ajax/libs/dojo/1.4.4/dojo");
dojo.registerModulePath("dojox", "https://ajax.googleapis.com/ajax/libs/dojo/1.4.4/dojox");
dojo.require("dojox.highlight");
dojo.require("dojox.highlight.languages.javascript");
dojo.require("dojox.highlight.languages.html");
dojo.ready(function() {
dojo.query("pre > code")
.forEach(function(node) {
if (node.innerHTML.indexOf("DOCTYPE") !== -1 || node.innerHTML.indexOf('<script') !== -1) {
dojo.addClass(node, "html");
} else {
dojo.addClass(node, "javascript");
}
})
.forEach(dojox.highlight.init);
});
</script>
</head>
<body>
<div id="grid"></div>
<div id="wrapper">
<div id="navBg"></div>
<button type="button" role="button" aria-label="Toggle Navigation" class="off-canvas-button">
<span class="lines">
<span class="line"> </span>
<span class="line"> </span>
<span class="line"> </span>
</span>
<span class="cross">×</span>
</button>
<div id="nav" class="mono">
<a class="homeImageLink" href="HOMEPATH"></a>
<h1>a javascript module loader</h1>
<ul>
<li class="hbox">
<a href="HOMEPATH">Home</a>
<span class="spacer boxFlex"></span>
<span class="icon home"></span>
</li>
</ul>
<ul>
<li class="hbox">
<a class="local" href="start.html">Start</a>
<span class="spacer boxFlex"></span>
<span class="icon start"></span>
</li>
<li class="hbox">
<a class="local" href="download.html">Download</a>
<span class="spacer boxFlex"></span>
<span class="icon download"></span>
</li>
<li class="hbox">
<a class="local" href="api.html">API</a>
<span class="spacer boxFlex"></span>
<span class="icon api"></span>
</li>
<li class="hbox">
<a class="local" href="optimization.html">Optimization</a>
<span class="spacer boxFlex"></span>
<span class="icon optimize"></span>
</li>
</ul>
<ul>
<li class="hbox">
<a class="local" href="jquery.html">Use with jQuery</a>
<span class="spacer boxFlex"></span>
<span class="icon script"></span>
</li>
<li class="hbox">
<a class="local" href="node.html">Use with Node</a>
<span class="spacer boxFlex"></span>
<span class="icon script"></span>
</li>
<li class="hbox">
<a class="local" href="dojo.html">Use with Dojo</a>
<span class="spacer boxFlex"></span>
<span class="icon script"></span>
</li>
<li class="hbox">
<a class="local" href="commonjs.html">CommonJS Notes</a>
<span class="spacer boxFlex"></span>
<span class="icon script"></span>
</li>
</ul>
<ul>
<li class="hbox">
<a class="local" href="faq.html">FAQs</a>
<span class="spacer boxFlex"></span>
<span class="icon question"></span>
</li>
<li class="hbox">
<a class="local" href="errors.html">Common Errors</a>
<span class="spacer boxFlex"></span>
<span class="icon question"></span>
</li>
<li class="hbox">
<a class="local" href="plugins.html">Writing Plugins</a>
<span class="spacer boxFlex"></span>
<span class="icon api"></span>
</li>
</ul>
<ul>
<li class="hbox">
<a class="local" href="why.html">Why Web Modules</a>
<span class="spacer boxFlex"></span>
<span class="icon question"></span>
</li>
<li class="hbox">
<a class="local" href="whyamd.html">Why AMD</a>
<span class="spacer boxFlex"></span>
<span class="icon question"></span>
</li>
<li class="hbox">
<a class="local" href="requirements.html">Requirements</a>
<span class="spacer boxFlex"></span>
<span class="icon requirement"></span>
</li>
<li class="hbox">
<a class="local" href="history.html">History</a>
<span class="spacer boxFlex"></span>
<span class="icon history"></span>
</li>
</ul>
<ul>
<li class="hbox">
<a href="https://stackoverflow.com/questions/tagged/requirejs">Get Help</a>
<span class="spacer boxFlex"></span>
<span class="icon help"></span>
</li>
<li class="hbox">
<a href="https://jrburke.com/">Blog</a>
<span class="spacer boxFlex"></span>
<span class="icon blog"></span>
</li>
<li class="hbox">
<a href="https://twitter.com/jrburke">Twitter</a>
<span class="spacer boxFlex"></span>
<span class="icon twitter"></span>
</li>
</ul>
<ul>
<li class="hbox">
<a href="https://github.com/requirejs/requirejs">GitHub</a>
<span class="spacer boxFlex"></span>
<span class="icon git"></span>
</li>
<li class="hbox">
<a class="local" href="contributing.html">Contributing</a>
<span class="spacer boxFlex"></span>
<span class="icon fork"></span>
</li>
</ul>
<ul>
<li class="version">2.3.8 Docs (<a href="https://github.com/requirejs/requirejs/wiki/Upgrading-to-RequireJS-2.1">upgrade info</a>)</li>
</ul>
</div>
<div id="content">
================================================
FILE: docs/api.html
================================================
<div id="directory" class="section">
<h1>RequireJS API</h1>
<ul class="index mono">
<li class="hbox"><a href="#usage">Usage</a><span class="spacer boxFlex"></span><span class="sect">§§ 1-1.3</span></li>
<ul>
<li class="hbox"><a href="#jsfiles">Load JavaScript Files</a><span class="spacer boxFlex"></span><span class="sect">§ 1.1</span></li>
<li class="hbox"><a href="#data-main">data-main Entry Point</a><span class="spacer boxFlex"></span><span class="sect">§ 1.2</span></li>
<li class="hbox"><a href="#define">Define a Module</a><span class="spacer boxFlex"></span><span class="sect">§ 1.3</span></li>
<ul>
<li class="hbox"><a href="#defsimple">Simple Name/Value Pairs</a><span class="spacer boxFlex"></span><span class="sect">§ 1.3.1</span></li>
<li class="hbox"><a href="#deffunc">Definition Functions</a><span class="spacer boxFlex"></span><span class="sect">§ 1.3.2</span></li>
<li class="hbox"><a href="#defdep">Definition Functions with Dependencies</a><span class="spacer boxFlex"></span><span class="sect">§ 1.3.3</span></li>
<li class="hbox"><a href="#funcmodule">Define a Module as a Function</a><span class="spacer boxFlex"></span><span class="sect">§ 1.3.4</span></li>
<li class="hbox"><a href="#cjsmodule">Define a Module with Simplified CommonJS Wrapper</a><span class="spacer boxFlex"></span><span class="sect">§ 1.3.5</span></li>
<li class="hbox"><a href="#modulename">Define a Module with a name</a><span class="spacer boxFlex"></span><span class="sect">§ 1.3.6</span></li>
<li class="hbox"><a href="#modulenotes">Other Module Notes</a><span class="spacer boxFlex"></span><span class="sect">§ 1.3.7</span></li>
<li class="hbox"><a href="#circular">Circular Dependencies</a><span class="spacer boxFlex"></span><span class="sect">§ 1.3.8</span></li>
<li class="hbox"><a href="#jsonp">Specify a JSONP Service Dependency</a><span class="spacer boxFlex"></span><span class="sect">§ 1.3.9</span></li>
<li class="hbox"><a href="#undef">Undefining a Module</a><span class="spacer boxFlex"></span><span class="sect">§ 1.3.10</span></li>
</ul>
</ul>
<li class="hbox"><a href="#mechanics">Mechanics</a><span class="spacer boxFlex"></span><span class="sect">§§ 2</span></li>
<li class="hbox"><a href="#config">Configuration Options</a><span class="spacer boxFlex"></span><span class="sect">§§ 3</span></li>
<li class="hbox"><a href="#advanced">Advanced Usage</a><span class="spacer boxFlex"></span><span class="sect">§§ 4-4.6</span></li>
<ul>
<li class="hbox"><a href="#packages">Loading Modules from Packages</a><span class="spacer boxFlex"></span><span class="sect">§ 4.1</span></li>
<li class="hbox"><a href="#multiversion">Multiversion Support</a><span class="spacer boxFlex"></span><span class="sect">§ 4.2</span></li>
<li class="hbox"><a href="#afterload">Loading Code After Page Load</a><span class="spacer boxFlex"></span><span class="sect">§ 4.3</span></li>
<li class="hbox"><a href="#webworker">Web Worker Support</a><span class="spacer boxFlex"></span><span class="sect">§ 4.4</span></li>
<li class="hbox"><a href="#rhino">Rhino Support</a><span class="spacer boxFlex"></span><span class="sect">§ 4.5</span></li>
<li class="hbox"><a href="#nashorn">Nashorn Support</a><span class="spacer boxFlex"></span><span class="sect">§ 4.6</span></li>
<li class="hbox"><a href="#errors">Handling Errors</a><span class="spacer boxFlex"></span><span class="sect">§ 4.7</span></li>
</ul>
<li class="hbox"><a href="#plugins">Loader Plugins</a><span class="spacer boxFlex"></span><span class="sect">§§ 5-5.4</span></li>
<ul>
<li class="hbox"><a href="#text">Specify a Text File Dependency</a><span class="spacer boxFlex"></span><span class="sect">§ 5.1</span></li>
<li class="hbox"><a href="#pageload">Page Load Event Support/DOM Ready</a><span class="spacer boxFlex"></span><span class="sect">§ 5.2</span></li>
<li class="hbox"><a href="#i18n">Define an I18N Bundle</a><span class="spacer boxFlex"></span><span class="sect">§ 5.3</span></li>
</ul>
</ul>
</div>
<div class="section">
<h2>
<a href="#usage" name="usage">Usage</a>
<span class="sectionMark">§ 1</span>
</h2>
<h3>
<a href="#jsfiles" name="jsfiles">Load JavaScript Files</a>
<span class="sectionMark">§ 1.1</span>
</h3>
<p>RequireJS takes a different approach to script loading than traditional <script> tags. While it can also run fast and optimize well, the primary goal is to encourage modular code. As part of that, it encourages using <strong>module IDs</strong> instead of URLs for script tags.</p>
<p>RequireJS loads all code relative to a <a href="#config-baseUrl">baseUrl</a>. The baseUrl is normally set to the same directory as the script used in a data-main attribute for the top level script to load for a page. The <a href="#data-main">data-main attribute</a> is a special attribute that require.js will check to start script loading. This example will end up with a baseUrl of <strong>scripts</strong>:</p>
<pre><code><!--This sets the baseUrl to the "scripts" directory, and
loads a script that will have a module ID of 'main'-->
<script data-main="scripts/main.js" src="scripts/require.js"></script>
</code></pre>
<p>Or, baseUrl can be set manually via the <a href="#config">RequireJS config</a>. If there is no explicit config and data-main is not used, then the default baseUrl is the directory that contains the HTML page running RequireJS.</p>
<p>RequireJS also assumes by default that all dependencies are scripts, so it does not expect to see a trailing ".js" suffix on module IDs. RequireJS will automatically add it when translating the module ID to a path. With the <a href="#config-paths">paths config</a>, you can set
up locations of a group of scripts. All of these capabilities allow you to use smaller strings for scripts as compared to traditional <script> tags.</p>
<p>There may be times when you do want to reference a script directly and not conform to the "baseUrl + paths" rules for finding it. If a module ID has one of the following characteristics, the ID will not be passed through the "baseUrl + paths" configuration, and just be treated like a regular URL that is relative to the document:</p>
<ul>
<li>Ends in ".js".</li>
<li>Starts with a "/".</li>
<li>Contains an URL protocol, like "http:" or "https:".</li>
</ul>
<p>In general though, it is best to use the baseUrl and "paths" config to set paths for module IDs. By doing so, it gives you more flexibility in renaming and configuring the paths to different locations for optimization builds.</p>
<p>Similarly, to avoid a bunch of configuration, it is best to avoid deep folder hierarchies for scripts, and instead either keep all the scripts in baseUrl, or if you want to separate your library/vendor-supplied code from your app code, use a directory layout like this:</p>
<ul>
<li>www/
<ul>
<li>index.html</li>
<li>js/
<ul>
<li>app/
<ul>
<li>sub.js</li>
</ul>
</li>
<li>lib/
<ul>
<li>jquery.js</li>
<li>canvas.js</li>
</ul></li>
<li>app.js</li>
<li>require.js</li>
</ul></li>
</ul></li>
</ul>
<p>in index.html:</p>
<pre><code><script data-main="js/app.js" src="js/require.js"></script></code></pre>
<p>and in app.js:</p>
<pre><code>requirejs.config({
//By default load any module IDs from js/lib
baseUrl: 'js/lib',
//except, if the module ID starts with "app",
//load it from the js/app directory. paths
//config is relative to the baseUrl, and
//never includes a ".js" extension since
//the paths config could be for a directory.
paths: {
app: '../app'
}
});
// Start the main app logic.
requirejs(['jquery', 'canvas', 'app/sub'],
function ($, canvas, sub) {
//jQuery, canvas and the app/sub module are all
//loaded and can be used here now.
});
</code></pre>
<p>Notice as part of that example, vendor libraries like jQuery did not have their version numbers in their file names. It is recommended to store that version info in a separate text file if you want to track it, or if you use a tool like <a href="https://github.com/volojs/volo">volo</a>, it will stamp the package.json with the version information but keep the file on disk as "jquery.js". This allows you to have the very minimal configuration instead of having to put an entry in the "paths" config for each library. For instance, configure "jquery" to be "jquery-1.7.2".</p>
<p>Ideally the scripts you load will be modules that are defined by calling <a href="#define">define()</a>. However, you may need to use some traditional/legacy "browser globals" scripts that do not express their dependencies via define(). For those, you can use the <a href="#config-shim">shim config</a>. To properly express their dependencies.</p>
<p>If you do not express the dependencies, you will likely get loading errors since RequireJS loads scripts asynchronously and out of order for speed.</p>
<h3>
<a href="#data-main" name="data-main">data-main Entry Point</a>
<span class="sectionMark">§ 1.2</span>
</h3>
<p>The data-main attribute is a special attribute that require.js will check to start script loading:</p>
<pre><code><!--when require.js loads it will inject another script tag
(with async attribute) for scripts/main.js-->
<script data-main="scripts/main" src="scripts/require.js"></script>
</code></pre>
<p>You will typically use a data-main script to <a href="#config">set configuration options</a> and then load the first application module. Note: the script tag require.js generates for your data-main module includes the <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-async">async attribute</a>. This means that <strong>you cannot assume that the load and execution of your data-main script will finish prior to other scripts referenced later in the same page.</strong></p>
<p>For example, this arrangement will fail randomly when the require.config path for the 'foo' module has not been set prior to it being require()'d later:</p>
<pre><code><script data-main="scripts/main" src="scripts/require.js"></script>
<script src="scripts/other.js"></script>
</code></pre>
<pre><code>// contents of main.js:
require.config({
paths: {
foo: 'libs/foo-1.1.3'
}
});
</code></pre>
<pre><code>// contents of other.js:
// This code might be called before the require.config() in main.js
// has executed. When that happens, require.js will attempt to
// load 'scripts/foo.js' instead of 'scripts/libs/foo-1.1.3.js'
require(['foo'], function(foo) {
});
</code></pre>
<p>If you want to do <code>require()</code> calls in the HTML page, then it is best to not use data-main. data-main is only intended for use when the page just has one main entry point, the data-main script. For pages that want to do inline <code>require()</code> calls, it is best to nest those inside a <code>require()</code> call for the configuration:</p>
<pre><code><script src="scripts/require.js"></script>
<script>
require(['scripts/config'], function() {
// Configuration loaded now, safe to do other require calls
// that depend on that config.
require(['foo'], function(foo) {
});
});
</script>
</code></pre>
<h3>
<a href="#define" name="define">Define a Module</a>
<span class="sectionMark">§ 1.3</span>
</h3>
<p>A module is different from a traditional script file in that it defines a well-scoped object that avoids polluting the global namespace. It can explicitly list its dependencies and get a handle on those dependencies without needing to refer to global objects, but instead receive the dependencies as arguments to the function that defines the module. Modules in RequireJS are an extension of the <a href="http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth">Module Pattern</a>, with the benefit of not needing globals to refer to other modules.</p>
<p>The RequireJS syntax for modules allows them to be loaded as fast as possible, even out of order, but evaluated in the correct dependency order, and since global variables are not created, it makes it possible to <a href="#multiversion">load multiple versions of a module in a page</a>.</p>
<p>(If you are familiar with or are using CommonJS modules, then please also see <a href="commonjs.html">CommonJS Notes</a> for information on how the RequireJS module format maps to CommonJS modules).</p>
<p>There should only be <strong>one</strong> module definition per file on disk. The modules can be grouped into optimized bundles by the <a href="optimization.html">optimization tool</a>.</p>
<div class="subSection">
<h4>
<a href="#defsimple" name="defsimple">Simple Name/Value Pairs</a>
<span class="sectionMark">§ 1.3.1</span>
</h4>
<p>If the module does not have any dependencies, and it is just a collection of name/value pairs, then just pass an object literal to define():</p>
<pre><code>//Inside file my/shirt.js:
define({
color: "black",
size: "unisize"
});
</code></pre>
</div>
<div class="subSection">
<h4>
<a href="#deffunc" name="deffunc">Definition Functions</a>
<span class="sectionMark">§ 1.3.2</span>
</h4>
<p>If the module does not have dependencies, but needs to use a function to do some setup work, then define itself, pass a function to define():</p>
<pre><code>//my/shirt.js now does setup work
//before returning its module definition.
define(function () {
//Do setup work here
return {
color: "black",
size: "unisize"
}
});
</code></pre>
</div>
<div href="#subSection" class="subSection">
<h4><a href="#defdep" name="defdep">Definition Functions with Dependencies</a><span class="sectionMark">§ 1.3.3</span></h4>
<p>If the module has dependencies, the first argument should be an array of dependency names, and the second argument should be a definition function. The function will be called to define the module once all dependencies have loaded. The function should return an object that defines the module. The dependencies will be passed to the definition function as function arguments, listed in the same order as the order in the dependency array:</p>
<pre><code>//my/shirt.js now has some dependencies, a cart and inventory
//module in the same directory as shirt.js
define(["./cart", "./inventory"], function(cart, inventory) {
//return an object to define the "my/shirt" module.
return {
color: "blue",
size: "large",
addToCart: function() {
inventory.decrement(this);
cart.add(this);
}
}
}
);
</code></pre>
<p>In this example, a my/shirt module is created. It depends on my/cart and my/inventory. On disk, the files are structured like this:</p>
<ul>
<li>my/cart.js</li>
<li>my/inventory.js</li>
<li>my/shirt.js</li>
</ul>
<p>The function call above specifies two arguments, "cart" and "inventory". These are the modules represented by the "./cart" and "./inventory" module names.</p>
<p>The function is not called until the my/cart and my/inventory modules have been loaded, and the function receives the modules as the "cart" and "inventory" arguments.</p>
<p>Modules that define globals are explicitly discouraged, so that multiple versions of a module can exist in a page at a time (see <strong>Advanced Usage</strong>). Also, the order of the function arguments should match the order of the dependencies.</p>
<p>The return object from the function call defines the "my/shirt" module. By defining modules in this way, "my/shirt" does not exist as a global object.</p>
</div>
<div class="subSection">
<h4><a href="#funcmodule" name="funcmodule">Define a Module as a Function</a><span class="sectionMark">§ 1.3.4</span></h4>
<p>Modules do not have to return objects. Any valid return value from a function is allowed. Here is a module that returns a function as its module definition:</p>
<pre><code>//A module definition inside foo/title.js. It uses
//my/cart and my/inventory modules from before,
//but since foo/title.js is in a different directory than
//the "my" modules, it uses the "my" in the module dependency
//name to find them. The "my" part of the name can be mapped
//to any directory, but by default, it is assumed to be a
//sibling to the "foo" directory.
define(["my/cart", "my/inventory"],
function(cart, inventory) {
//return a function to define "foo/title".
//It gets or sets the window title.
return function(title) {
return title ? (window.title = title) :
inventory.storeName + ' ' + cart.name;
}
}
);
</code></pre>
</div>
<div class="subSection">
<h4><a href="#cjsmodule" name="cjsmodule">Define a Module with Simplified CommonJS Wrapper</a><span class="sectionMark">§ 1.3.5</span></h4>
<p>If you wish to reuse some code that was written in the traditional <a href="http://wiki.commonjs.org/wiki/Modules/1.1.1">CommonJS module format</a> it may be difficult to re-work to the array of dependencies used above, and you may prefer to have
direct alignment of dependency name to the local variable used for that dependency. You can use the <a href="commonjs.html">simplified CommonJS wrapper</a> for those cases:</p>
<pre><code>define(function(require, exports, module) {
var a = require('a'),
b = require('b');
//Return the module value
return function () {};
}
);
</code></pre>
<p>This wrapper relies on Function.prototype.toString() to give a useful string value of the function contents. This does not work on some devices like the PS3 and some older Opera mobile browsers. Use the <a href="optimization.html">optimizer</a> to pull out the dependencies in the array format for use on those devices.</p>
<p>More information is available on the <a href="commonjs.html">CommonJS page</a>, and in the <a href="whyamd.html#sugar">"Sugar" section in the Why AMD page</a>.
</div>
<div class="subSection">
<h4><a href="#modulename" name="modulename">Define a Module with a Name</a><span class="sectionMark">§ 1.3.6</span></h4>
<p>You may encounter some define() calls that include a name for the module as the first argument to define():</p>
<pre><code> //Explicitly defines the "foo/title" module:
define("foo/title",
["my/cart", "my/inventory"],
function(cart, inventory) {
//Define foo/title object in here.
}
);
</code></pre>
<p>These are normally generated by the <a href="optimization.html">optimization tool</a>. You can explicitly name modules yourself, but it makes the modules less portable -- if you move the file to another directory you will need to change the name. It is normally best to avoid coding in a name for the module and just let the optimization tool burn in the module names. The optimization tool needs to add the names so that more than one module can be bundled in a file, to allow for faster loading in the browser.</p>
</div>
<div class="subSection">
<h4><a href="#modulenotes" name="modulenotes">Other Module Notes</a><span class="sectionMark">§ 1.3.7</span></h4>
<p id="modulenotes-onemodule"><strong>One module per file.</strong>: Only one module should be defined per JavaScript file, given the nature of the module name-to-file-path lookup algorithm. You should only use the <a href="optimization.html">optimization tool</a> to group multiple modules into optimized files.</p>
<p id="modulenotes-relative"><strong>Relative module names inside define()</strong>: For require("./relative/name") calls that can happen inside a define() function call, be sure to ask for "require" as a dependency, so that the relative name is resolved correctly:</p>
<pre><code>define(["require", "./relative/name"], function(require) {
var mod = require("./relative/name");
});
</code></pre>
<p>Or better yet, use the shortened syntax that is available for use with <a href="commonjs.html">translating CommonJS</a> modules:</p>
<pre><code>define(function(require) {
var mod = require("./relative/name");
});
</code></pre>
<p>This form will use Function.prototype.toString() to find the require() calls, and add them to the dependency array, along with "require", so the code will work correctly with relative paths.</p>
<p>Relative paths are really useful if you are creating a few modules inside a directory, so that you can share the directory with other people or other projects, and you want to be able to get a handle on the sibling modules in that directory without
having to know the directory's name.</p>
<p id="modulenotes-relative-names"><strong>Relative module names are relative to other names, not paths</strong>: The loader stores modules by their name and not by their path internally. So for relative name references, those are resolved relative to the module name making the reference, then that module name, or ID, is converted to a path if needs to be loaded. Example code for a 'compute' package that has a 'main' and 'extras' modules in it:</p>
<pre><code>* lib/
* compute/
* main.js
* extras.js
</code></pre>
<p>where the main.js module looks like this:</p>
<pre><code>define(["./extras"], function(extras) {
//Uses extras in here.
});
</code></pre>
<p>If this was the paths config:</p>
<pre><code>require.config({
baseUrl: 'lib',
paths: {
'compute': 'compute/main'
}
});
</code></pre>
<p>And a <code>require(['compute'])</code> is done, then lib/compute/main.js will have the module name of 'compute'. When it asks for './extras', that is resolved relative to 'compute', so 'compute/./extras', which normalizes to just 'extras'. Since there is no paths config for that module name, the path generated will be for 'lib/extras.js', which is incorrect.</p>
<p>For this case, <a href="#packages">packages config</a> is a better option, since it allows setting the main module up as 'compute', but internally the loader will store the module with the ID of 'compute/main' so that the relative reference for './extras' works.</p>
<p>Another option is to construct a module at lib/compute.js that is just <code>define(['./compute/main'], function(m) { return m; });</code>, then there is no need for paths or packages config.</p>
<p>Or, do not set that paths or packages config and do the top level require call as <code>require(['compute/main'])</code>.</p>
<p id="modulenotes-urls"><strong>Generate URLs relative to module</strong>: You may need to generate an URL that is relative to a module. To do so, ask for "require" as a dependency and then use require.toUrl() to generate the URL:</p>
<pre><code>define(["require"], function(require) {
var cssUrl = require.toUrl("./style.css");
});
</code></pre>
<p id="modulenotes-console"><strong>Console debugging</strong>: If you need to work with a module you already loaded via a <code>require(["module/name"], function(){})</code> call in the JavaScript console, then you can use the require() form that just uses the string name of the module to fetch it:</p>
<pre><code>require("module/name").callSomeFunction()
</code></pre>
<p>Note this only works if "module/name" was previously loaded via the async version of require: <code>require(["module/name"])</code>. If using a relative path, like './module/name', those only work inside define</p>
</div>
<div class="subSection">
<h4><a href="#circular" name="circular">Circular Dependencies</a><span class="sectionMark">§ 1.3.8</span></h4>
<p>If you define a circular dependency ("a" needs "b" and "b" needs "a"), then in this case when "b"'s module function is called, it will get an undefined value for "a". "b" can fetch "a" later after modules have been defined by using the require() method (be sure to specify require as a dependency so the right context is used to look up "a"):</p>
<pre><code>//Inside b.js:
define(["require", "a"],
function(require, a) {
//"a" in this case will be null if "a" also asked for "b",
//a circular dependency.
return function(title) {
return require("a").doSomething();
}
}
);
</code></pre>
<p>Normally you should not need to use require() to fetch a module, but instead rely on the module being passed in to the function as an argument. Circular dependencies are rare, and usually a sign that you might want to rethink the design. However, sometimes they are needed, and in that case, use require() as specified above.</p>
<p>If you are familiar with CommonJS modules, you could instead use <strong>exports</strong> to create an empty object for the module that is available immediately for reference by other modules. By doing this on both sides of a circular dependency, you can then safely hold on to the the other module. This only works if each module is exporting an object for the module value, not a function:</p>
<pre><code>//Inside b.js:
define(function(require, exports, module) {
//If "a" has used exports, then we have a real
//object reference here. However, we cannot use
//any of "a"'s properties until after "b" returns a value.
var a = require("a");
exports.foo = function () {
return a.bar();
};
});
</code></pre>
<p>Or, if you are using the dependency array approach, ask for the special
<a href="https://github.com/requirejs/requirejs/wiki/Differences-between-the-simplified-CommonJS-wrapper-and-standard-AMD-define#wiki-magic">'exports' dependency:</a></p>
<pre><code>//Inside b.js:
define(['a', 'exports'], function(a, exports) {
//If "a" has used exports, then we have a real
//object reference here. However, we cannot use
//any of "a"'s properties until after "b" returns a value.
exports.foo = function () {
return a.bar();
};
});
</code></pre>
</div>
<div class="subSection">
<h4><a href="#jsonp" name="jsonp">Specify a JSONP Service Dependency</a><span class="sectionMark">§ 1.3.9</span></h4>
<p><a href="http://en.wikipedia.org/wiki/JSON#JSONP">JSONP</a> is a way of calling some services in JavaScript. It works across domains and it is an established approach to calling services that just require an HTTP GET via a script tag.</p>
<p>To use a JSONP service in RequireJS, specify "define" as the callback parameter's value. This means you can get the value of a JSONP URL as if it was a module definition.</p>
<p>Here is an example that calls a JSONP API endpoint. In this example, the JSONP callback parameter is called "callback", so "callback=define" tells the API to wrap the JSON response in a "define()" wrapper:</p>
<pre><code>require(["http://example.com/api/data.json?callback=define"],
function (data) {
//The data object will be the API response for the
//JSONP data call.
console.log(data);
}
);
</code></pre>
<p>This use of JSONP should be limited to JSONP services for initial application setup. If the JSONP service times out, it means other modules you define via define() may not get executed, so the error handling is not robust.</p>
<p><strong>Only JSONP return values that are JSON objects are supported</strong>. A JSONP response that is an array, a string or a number will not work.</p>
<p>This functionality should not be used for long-polling JSONP connections -- APIs that deal with real time streaming. Those kinds of APIs should do more script cleanup after receiving each response, and RequireJS will only fetch a JSONP URL once -- subsequent uses of the same URL as a dependency in a require() or define() call will get a cached value.</p>
<p>Errors in loading a JSONP service are normally surfaced via timeouts for the service, since script tag loading does not give much detail into network problems. To detect errors, you can override requirejs.onError() to get errors. There is more information in the <a href="#errors">Handling Errors</a> section.</p>
</div>
<div class="subSection">
<h4><a href="#undef" name="undef">Undefining a Module</a><span class="sectionMark">§ 1.3.10</span></h4>
<p>There is a global function, <b>requirejs.undef()</b>, that allows undefining a module. It will reset the
loader's internal state to forget about the previous definition of the module.</p>
<p><b>However</b>, it will not remove the module from other modules that are already defined and got a
handle on that module as a dependency when they executed. So it is really only useful to use in
error situations when no other modules have gotten a handle on a module value, or as part of any future
module loading that may use that module. See the <a href="#errbacks">errback section</a> for an example.</p>
<p>If you want to do more sophisticated dependency graph analysis for undefining work, the semi-private
<a href="https://github.com/requirejs/requirejs/wiki/Internal-API:-onResourceLoad">onResourceLoad API</a> may be helpful.</p>
</div>
</div>
<div class="section">
<h2>
<a href="#mechanics" name="mechanics">Mechanics</a>
<span class="sectionMark">§ 2</span>
</h2>
<p>RequireJS loads each dependency as a script tag, using head.appendChild().</p>
<p>RequireJS waits for all dependencies to load, figures out the right order in which to call the functions that define the modules, then calls the module definition functions once the dependencies for those functions have been called. Note that the dependencies for a given module definition function could be called in any order, due to their sub-dependency relationships and network load order.</p>
<p>Using RequireJS in a server-side JavaScript environment that has synchronous loading should be as easy as redefining require.load(). The build system does this, the require.load method for that environment can be found in build/jslib/requirePatch.js.</p>
<p>In the future, this code may be pulled into the require/ directory as an optional module that you can load in your env to get the right load behavior based on the host environment.</p>
</div>
<div class="section">
<h2>
<a href="#config" name="config">Configuration Options</a>
<span class="sectionMark">§ 3</span>
</h2>
<p>When using require() in the top-level HTML page (or top-level script file that does not define a module), a configuration object can be passed as the first option:</p>
<pre><code><script src="scripts/require.js"></script>
<script>
require.config({
baseUrl: "/another/path",
paths: {
"some": "some/v1.0"
},
waitSeconds: 15
});
require( ["some/module", "my/module", "a.js", "b.js"],
function(someModule, myModule) {
//This function will be called when all the dependencies
//listed above are loaded. Note that this function could
//be called before the page is loaded.
//This callback is optional.
}
);
</script>
</code></pre>
<p>You may also call require.config from your <a href="api.html#data-main">data-main Entry Point</a>, but be aware that the data-main script is loaded asynchronously. Avoid other entry point scripts which wrongly assume that data-main and its require.config will always execute prior to their script loading.</a></p>
<p>Also, you can define the config object as the global variable <code>require</code> <strong>before</strong> require.js is loaded, and have the values applied automatically.
This example specifies some dependencies to load as soon as require.js defines require():</p>
<pre><code><script>
var require = {
deps: ["some/module1", "my/module2", "a.js", "b.js"],
callback: function(module1, module2) {
//This function will be called when all the dependencies
//listed above in deps are loaded. Note that this
//function could be called before the page is loaded.
//This callback is optional.
}
};
</script>
<script src="scripts/require.js"></script>
</code></pre>
<p><b>Note:</b> It is best to use <code>var require = {}</code> and do not use
<code>window.require = {}</code>, it will not behave correctly in IE.</p>
<p>There are <a href="https://github.com/requirejs/requirejs/wiki/Patterns-for-separating-config-from-the-main-module">some patterns for separating the config from main module loading</a>.</p>
<p>Supported configuration options:</p>
<p id="config-baseUrl"><strong><a href="#config-baseUrl">baseUrl</a></strong>: the root path to use for all module lookups. So in the above example, "my/module"'s script tag will have a src="/another/path/my/module.js". baseUrl is <strong>not</strong> used when loading plain .js files (indicated by a dependency string <a href="#jsfiles">starting with a slash, has a protocol, or ends in .js</a>), those strings are used as-is, so a.js and b.js will be loaded from the same directory as the HTML page that contains the above snippet.</p>
<p>If no baseUrl is explicitly set in the configuration, the default value will be the location of the HTML page that loads require.js. If a <strong>data-main</strong> attribute is used, that path will become the baseUrl.</p>
<p>The baseUrl can be a URL on a different domain as the page that will load require.js. RequireJS script loading works across domains. The only restriction is on text content loaded by text! plugins: those paths should be on the same domain as the page, at least during development. The optimization tool will inline text! plugin resources so after using the optimization tool, you can use resources that reference text! plugin resources from another domain.</p>
<p id="config-paths"><strong><a href="#config-paths">paths</a></strong>: path mappings for module names not found directly under baseUrl. The path settings are assumed to be relative to baseUrl, unless the paths setting starts with a "/" or has a URL protocol in it ("like http:"). Using the above sample config, "some/module"'s script tag will be src="/another/path/some/v1.0/module.js".</p>
<p>The path that is used for a module name should <strong>not</strong> include an extension, since the path mapping could be for a directory. The path mapping code will automatically add the .js extension when mapping the module name to a path. If <a href="#modulenotes-urls">require.toUrl()</a> is used, it will add the appropriate extension, if it is for something like a text template.</p>
<p>When run in a browser, <a href="#pathsfallbacks">paths fallbacks</a> can be specified, to allow trying a load from a CDN location, but falling back to a local location if the CDN location fails to load.</p>
<p id="config-bundles"><strong><a href="#config-bundles">bundles</a></strong>: Introduced in RequireJS 2.1.10: allows configuring multiple module IDs to be found in another script. Example:</p>
<pre><code>requirejs.config({
bundles: {
'primary': ['main', 'util', 'text', 'text!template.html'],
'secondary': ['text!secondary.html']
}
});
require(['util', 'text'], function(util, text) {
//The script for module ID 'primary' was loaded,
//and that script included the define()'d
//modules for 'util' and 'text'
});
</code></pre>
<p>That config states: modules 'main', 'util', 'text' and 'text!template.html' will be found by loading module ID 'primary'. Module 'text!secondary.html' can be found by loading module ID 'secondary'.
</p>
<p>This only sets up where to find a module inside a script that has multiple define()'d modules in it. It does not automatically bind those modules to the bundle's module ID. The bundle's module ID is just used for locating the set of modules.</p>
<p>Something similar is possible with paths config, but it is much wordier, and the paths config route does not allow loader plugin resource IDs in its configuration, since the paths config values are path segments, not IDs.</p>
<p>bundles config is useful if doing a build and that build target was not an existing module ID, or if you have loader plugin resources in built JS files that should not be loaded by the loader plugin. <strong>Note that the keys and values are module IDs</strong>, not path segments. They are absolute module IDs, not a module ID prefix like <a href="#config-paths">paths config</a> or <a href="#config-map">map config</a>. Also, bundle config is different from map config in that map config is a one-to-one module ID relationship, where bundle config is for pointing multiple module IDs to a bundle's module ID.</p>
<p>As of RequireJS 2.2.0, the optimizer can generate the bundles config and insert it into the top level requirejs.config() call. See the <a href="https://github.com/requirejs/r.js/blob/98a9949480d68a781c8d6fc4ce0a07c16a2c8a2a/build/example.build.js#L641">bundlesConfigOutFile</a> build config option for more details.</p>
<p id="config-shim"><strong><a href="#config-shim">shim</a></strong>: Configure the dependencies, exports, and custom initialization for older, traditional "browser globals" scripts that do not use define() to declare the dependencies and set a module value.</p>
<p>Here is an example. It requires RequireJS 2.1.0+, and assumes backbone.js, underscore.js and jquery.js have been installed in the baseUrl directory. If not, then you may need to set a paths config for them:</p>
<pre><code>requirejs.config({
//Remember: only use shim config for non-AMD scripts,
//scripts that do not already call define(). The shim
//config will not work correctly if used on AMD scripts,
//in particular, the exports and init config will not
//be triggered, and the deps config will be confusing
//for those cases.
shim: {
'backbone': {
//These script dependencies should be loaded before loading
//backbone.js
deps: ['underscore', 'jquery'],
//Once loaded, use the global 'Backbone' as the
//module value.
exports: 'Backbone'
},
'underscore': {
exports: '_'
},
'foo': {
deps: ['bar'],
exports: 'Foo',
init: function (bar) {
//Using a function allows you to call noConflict for
//libraries that support it, and do other cleanup.
//However, plugins for those libraries may still want
//a global. "this" for the function will be the global
//object. The dependencies will be passed in as
//function arguments. If this function returns a value,
//then that value is used as the module export value
//instead of the object found via the 'exports' string.
//Note: jQuery registers as an AMD module via define(),
//so this will not work for jQuery. See notes section
//below for an approach for jQuery.
return this.Foo.noConflict();
}
}
}
});
//Then, later in a separate file, call it 'MyModel.js', a module is
//defined, specifying 'backbone' as a dependency. RequireJS will use
//the shim config to properly load 'backbone' and give a local
//reference to this module. The global Backbone will still exist on
//the page too.
define(['backbone'], function (Backbone) {
return Backbone.Model.extend({});
});
</code></pre>
<p>In RequireJS 2.0.*, the "exports" property in the shim config could have
been a function instead of a string. In that case, it functioned
the same as the "init" property as shown above. The "init" pattern is used in
RequireJS 2.1.0+ so a string value for <code>exports</code> can be used for
<a href="#config-enforceDefine">enforceDefine</a>, but then allow
functional work once the library is known to have loaded.</p>
<p>For "modules" that are just jQuery or Backbone plugins that do not need to export
any module value, the shim config can just be an array of dependencies:</p>
<pre><code>requirejs.config({
shim: {
'jquery.colorize': ['jquery'],
'jquery.scroll': ['jquery'],
'backbone.layoutmanager': ['backbone']
}
});
</code></pre>
<p>Note however if you want to get 404 load detection in IE so that you can use paths fallbacks or errbacks, then a string exports value should be given so the loader can check if the scripts actually
loaded (a return from init is <strong>not</strong> used for <code>enforceDefine</code> checking):</p>
<pre><code>requirejs.config({
shim: {
'jquery.colorize': {
deps: ['jquery'],
exports: 'jQuery.fn.colorize'
},
'jquery.scroll': {
deps: ['jquery'],
exports: 'jQuery.fn.scroll'
},
'backbone.layoutmanager': {
deps: ['backbone']
exports: 'Backbone.LayoutManager'
}
}
});
</code></pre>
<p><b>Important notes for "shim" config:</b></p>
<ul>
<li>The shim config only sets up code relationships. To load modules that
are part of or use shim config, a normal require/define call is needed. Setting shim by
itself does not trigger code to load.</li>
<li>Only use other "shim" modules as dependencies for shimmed scripts, or
AMD libraries that have no dependencies and call define() after they also
create a global (like jQuery or lodash). Otherwise, if you use an AMD
module as a dependency for a shim config module, after a build, that
AMD module may not be evaluated until after the shimmed code in the build
executes, and an error will occur. The ultimate fix is to upgrade all the
shimmed code to have optional AMD define() calls.</li>
<li>If it is not possible to upgrade the shimmed code to use AMD define()
calls, as of RequireJS 2.1.11, the optimizer has a
<a href="https://github.com/requirejs/r.js/blob/b8a6982d2923ae8389355edaa50d2b7f8065a01a/build/example.build.js#L68">wrapShim build option</a> that will
try to automatically wrap the shimmed code in a define() for a build. This
changes the scope of shimmed dependencies, so it is not guaranteed to always
work, but, for example, for shimmed dependencies that depend on an AMD version of Backbone,
it can be helpful.</li>
<li>The init function will <strong>not</strong> be called for AMD modules.
For example, you cannot use a shim init function to call jQuery's noConflict.
See <a href="jquery.html#noconflictmap">Mapping Modules to use noConflict</a>
for an alternate approach to jQuery.</li>
<li>Shim config is not supported when running AMD modules in node via RequireJS (it works for optimizer use though). Depending on the module being shimmed, it may fail in Node because Node does not have the same global environment as browsers. As of RequireJS 2.1.7, it will warn you in the console that shim config is not supported, and it may or may not work. If you wish to suppress that message, you can pass <code>requirejs.config({ suppress: { nodeShim: true }});</code>.</li>
</ul>
<p><b>Important optimizer notes for "shim" config</b>:</p>
<ul>
<li>You should use the <a href="optimization.html#mainConfigFile">mainConfigFile build option</a> to specify the file where to find the shim config. Otherwise the optimizer will not know of the shim config. The other option is to duplicate the shim config in the build profile.</li>
<li>Do not mix CDN loading with shim config in a build. Example scenario: you load jQuery from the CDN but use the shim config to load something like the stock version of Backbone that depends on jQuery. When you do the build, be sure to inline jQuery in the built file and do not load it from the CDN. Otherwise, Backbone will be inlined in the built file and it will execute before the CDN-loaded jQuery will load. This is because the shim config just delays loading of the files until dependencies are loaded, but does not do any auto-wrapping of define. After a build, the dependencies are already inlined, the shim config cannot delay execution of the non-define()'d code until later. define()'d modules do work with CDN loaded code after a build because they properly wrap their source in define factory function that will not execute until dependencies are loaded. So the lesson: shim config is a stop-gap measure for non-modular code, legacy code. define()'d modules are better.</li>
<li>For local, multi-file builds, the above CDN advice also applies. For any shimmed script, its dependencies <strong>must</strong> be loaded before the shimmed script executes. This means either building its dependencies directly in the buid layer that includes the shimmed script, or loading its dependencies with a <code>require([], function (){})</code> call, then doing a nested <code>require([])</code> call for the build layer that has the shimmed script.</li>
<li>If you are using uglifyjs to minify the code, <strong>do not</strong> set the uglify
option <code>toplevel</code> to true, or if using the command line
<strong>do not</strong> pass <code>-mt</code>. That option mangles
the global names that shim uses to find exports.</li>
</ul>
<p id="config-map"><strong><a href="#config-map">map</a></strong>: For the given module prefix, instead of loading the module with the given ID, substitute a different module ID.</p>
<p>This sort of capability is really important for larger projects which may have
two sets of modules that need to use two different versions of 'foo', but they
still need to cooperate with each other.</p>
<p>This is not possible with the <a href="#multiversion">context-backed multiversion support</a>. In addition, the <a href="#config-paths">paths config</a> is only for setting up root paths for module IDs, not for mapping one module ID to another one.</p>
<p>map example:</p>
<pre><code>requirejs.config({
map: {
'some/newmodule': {
'foo': 'foo1.2'
},
'some/oldmodule': {
'foo': 'foo1.0'
}
}
});
</code></pre>
<p>If the modules are laid out on disk like this:</p>
<ul>
<li>foo1.0.js</li>
<li>foo1.2.js</li>
<li>some/
<ul>
<li>newmodule.js</li>
<li>oldmodule.js</li>
</ul>
</li>
</ul>
<p>When 'some/newmodule' does `require('foo')` it will get the foo1.2.js file,
and when 'some/oldmodule' does `require('foo')` it will get the foo1.0.js file.</p>
<p>This feature only works well for scripts that are real AMD modules that call
define() and register as anonymous modules. Also, <strong>only use absolute module IDs</strong> for map config. Relative IDs (like <code>'../some/thing'</code>) do not work.</p>
<p>There is also support for a "*" map value which means "for all modules loaded, use this map config". If there is a more specific map config, that one will take precedence over the star config. Example:</p>
<pre><code>
requirejs.config({
map: {
'*': {
'foo': 'foo1.2'
},
'some/oldmodule': {
'foo': 'foo1.0'
}
}
});
</code></pre>
<p>Means that for any module except "some/oldmodule", when "foo" is wanted, use "foo1.2" instead. For "some/oldmodule" only, use "foo1.0" when it asks for "foo".</p>
<p id="config-map-notes"><strong>Note:</strong> when doing builds with map config, the map config needs to be fed to the optimizer, and the build output must still contain a requirejs config call that sets up the map config. The optimizer does not do ID renaming during the build, because some dependency references in a project could depend on runtime variable state. So the optimizer does not invalidate the need for a map config after the build.</p>
<p id="config-moduleconfig"><strong><a href="#config-moduleconfig">config</a></strong>: There is a common need to pass configuration info to a module. That configuration info is usually known as part of the application, and there needs to be a way to pass that down to a module. In RequireJS, that is done with the <b>config</b> option for requirejs.config(). Modules can then read that info by asking for the special dependency "module" and calling <b>module.config()</b>. Example:</p>
<pre><code>requirejs.config({
config: {
'bar': {
size: 'large'
},
'baz': {
color: 'blue'
}
}
});
//bar.js, which uses simplified CJS wrapping:
//https://requirejs.org/docs/whyamd.html#sugar
define(function (require, exports, module) {
//Will be the value 'large'
var size = module.config().size;
});
//baz.js which uses a dependency array,
//it asks for the special module ID, 'module':
//https://github.com/requirejs/requirejs/wiki/Differences-between-the-simplified-CommonJS-wrapper-and-standard-AMD-define#wiki-magic
define(['module'], function (module) {
//Will be the value 'blue'
var color = module.config().color;
});
</code></pre>
<p>For passing config to a <a href="#packages">package</a>, target the main module in the package,
not the package ID:</p>
<pre><code>requirejs.config({
//Pass an API key for use in the pixie package's
//main module.
config: {
'pixie/index': {
apiKey: 'XJKDLNS'
}
},
//Set up config for the "pixie" package, whose main
//module is the index.js file in the pixie folder.
packages: [
{
name: 'pixie',
main: 'index'
}
]
});
</code></pre>
<p id="config-packages"><strong><a href="#config-packages">packages</a></strong>: configures loading modules from CommonJS packages. See the <a href="#packages">packages topic</a> for more information.</p>
<p id="config-nodeIdCompat"><strong><a href="#config-nodeIdCompat">nodeIdCompat</a></strong>: Node treats module ID <code>example.js</code> and <code>example</code> the same. By default these are two different IDs in RequireJS. If you end up using modules installed from npm, then you may need to set this config value to <code>true</code> to avoid resolution issues. This option only applies to treating the ".js" suffix differently, it does not do any other node resolution and evaluation matching such as .json file handling (JSON handling needs a 'json!' loader plugin anyway). Available in 2.1.10 and greater.</p>
<p id="config-waitSeconds"><strong><a href="#config-waitSeconds">waitSeconds</a></strong>: The number of seconds to wait before giving up on loading a script. Setting it to 0 disables the timeout. The default is 7 seconds.</p>
<p id="config-context"><strong><a href="#config-context">context</a></strong>: A name to give to a loading context. This allows require.js to load multiple versions of modules in a page, as long as each top-level require call specifies a unique context string. To use it correctly, see the <a href="#multiversion">Multiversion Support</a> section.</p>
<p id="config-deps"><strong><a href="#config-deps">deps</a></strong>: An array of dependencies to load. Useful when require is defined as a config object before require.js is loaded, and you want to specify dependencies to load as soon as require() is defined. Using deps is just like doing a <code>require([])</code> call, but done as soon as the loader has processed the configuration. <strong>It does not block</strong>
any other require() calls from starting their requests for modules, it is just a way to specify
some modules to load asynchronously as part of a config block.</p>
<p id="config-callback"><strong><a href="#config-callback">callback</a></strong>: A function to execute after <strong>deps</strong> have been loaded. Useful when require is defined as a config object before require.js is loaded, and you want to specify a function to require after the configuration's <strong>deps</strong> array has been loaded.</p>
<p id="config-enforceDefine"><strong><a href="#config-enforceDefine">enforceDefine</a></strong>: If set to true, an error will be thrown if a script loads that does not call define() or have a shim exports string value that can be checked. See <a href="#ieloadfail">Catching load failures in IE</a> for more information.</p>
<p id="config-xhtml"><strong><a href="#config-xhtml">xhtml</a></strong>: If set to true, document.createElementNS() will be used to create script elements.</p>
<p id="config-urlArgs"><strong><a href="#config-urlArgs">urlArgs</a></strong>: Extra query string arguments appended to URLs that RequireJS uses to fetch resources. Most useful to cache bust when the browser or server is not configured correctly. Example cache bust setting for urlArgs:</p>
<pre><code>urlArgs: "bust=" + (new Date()).getTime()
</code></pre>
<p>As of RequireJS 2.2.0, urlArgs can be a function. If a function, it will receive the module ID and the URL as parameters, and it should return a string that will be added to the end of the URL. Return an empty string if no args. Be sure to take care of adding the '?' or '&' depending on the existing state of the URL. Example:</p>
<pre><code>requirejs.config({
urlArgs: function(id, url) {
var args = 'v=1';
if (url.indexOf('view.html') !== -1) {
args = 'v=2'
}
return (url.indexOf('?') === -1 ? '?' : '&') + args;
}
});
</code></pre>
<p>During development it can be useful to use this, however <strong>be sure</strong> to remove it before deploying your code.</p>
<p id="config-scriptType"><strong><a href="#config-scriptType">scriptType</a></strong>: Specify the value for the type="" attribute used for script tags inserted into the document by RequireJS. Default is "text/javascript". To use Firefox's JavaScript 1.8 features, use "text/javascript;version=1.8".</p>
<p id="config-skipDataMain"><strong><a href="#config-skipDataMain">skipDataMain</a></strong>: Introduced in RequireJS 2.1.9: If set to <code>true</code>, skips the <a href="#data-main">data-main attribute scanning</a> done to start module loading. Useful if RequireJS is embedded in a utility library that may interact with other RequireJS library on the page, and the embedded version should not do data-main loading.</p>
</div>
<div class="section">
<h2>
<a href="#advanced" name="advanced">Advanced Usage</a>
<span class="sectionMark">§ 4</span>
</h2>
<h3><a href="#packages" name="packages">Loading Modules from Packages</a><span class="sectionMark">§ 4.1</span></h3>
<p>RequireJS supports loading modules that are in a <a href="http://wiki.commonjs.org/wiki/Packages/1.1">CommonJS Packages</a> directory structure, but some additional configuration needs to be specified for it to work. Specifically, there is support for the following CommonJS Packages features:</p>
<ul>
<li>A package can be associated with a module name/prefix.</li>
<li>The package config can specify the following properties for a specific package:
<ul>
<li><strong>name</strong>: The name of the package (used for the module name/prefix mapping)</li>
<li><strong>location</strong>: The location on disk. Locations are relative to the baseUrl configuration value, unless they contain a protocol or start with a front slash (/).</li>
<li><strong>main</strong>: The name of the module inside the package that should be used when someone does a require for "packageName". The default value is "main", so only specify it if it differs from the default. The value is relative to the package folder.</li>
</ul></li>
</ul>
<p><strong>IMPORTANT NOTES</strong></p>
<ul>
<li>While the packages can have the CommonJS directory layout, the modules themselves should be in a module format that RequireJS can understand. Exception to the rule: if you are using the r.js Node adapter, the modules can be in the traditional CommonJS module format. You can use the <a href="commonjs.html#autoconversion">CommonJS converter tool</a> if you need to convert traditional CommonJS modules into the async module format that RequireJS uses.</li>
<li>Only one version of a package can be used in a project context at a time. You can use RequireJS <a href="#multiversion">multiversion support</a> to load two different module contexts, but if you want to use Package A and B in one context and they depend on different versions of Package C, then that will be a problem. This may change in the future.</li>
</ul>
<p>If you use a similar project layout as specified in the <a href="start.html">Start Guide</a>, the start of your web project would look something like this (Node/Rhino-based projects are similar, just use the contents of the <strong>scripts</strong> directory as the top-level project directory):</p>
<ul>
<li>project-directory/
<ul>
<li>project.html</li>
<li>scripts/
<ul>
<li>require.js</li>
</ul></li>
</ul></li>
</ul>
<p>Here is how the example directory layout looks with two packages, <strong>cart</strong> and <strong>store</strong>:</p>
<ul>
<li>project-directory/
<ul>
<li>project.html</li>
<li>scripts/
<ul>
<li>cart/
<ul>
<li>main.js</li>
</ul></li>
<li>store/
<ul>
<li>main.js</li>
<li>util.js</li>
</ul></li>
<li>main.js</li>
<li>require.js</li>
</ul></li>
</ul></li>
</ul>
<p><strong>project.html</strong> will have a script tag like this:</p>
<pre><code><script data-main="scripts/main" src="scripts/require.js"></script>
</code></pre>
<p>This will instruct require.js to load scripts/main.js. <strong>main.js</strong> uses the "packages" config to set up packages that are relative to require.js, which in this case are the source packages "cart" and "store":</p>
<pre><code>//main.js contents
//Pass a config object to require
require.config({
"packages": ["cart", "store"]
});
require(["cart", "store", "store/util"],
function (cart, store, util) {
//use the modules as usual.
});
</code></pre>
<p>A require of "cart" means that it will be loaded from <strong>scripts/cart/main.js</strong>, since "main" is the default main module setting supported by RequireJS. A require of "store/util" will be loaded from <strong>scripts/store/util.js</strong>.</p>
<p>If the "store" package did not follow the "main.js" convention, and looked more like this:</p>
<ul>
<li>project-directory/
<ul>
<li>project.html</li>
<li>scripts/
<ul>
<li>cart/
<ul>
<li>main.js</li>
</ul></li>
<li>store/
<ul>
<li>store.js</li>
<li>util.js</li>
</ul></li>
<li>main.js</li>
<li>package.json</li>
<li>require.js</li>
</ul></li>
</ul></li>
</ul>
<p>Then the RequireJS configuration would look like so:</p>
<pre><code>require.config({
packages: [
"cart",
{
name: "store",
main: "store"
}
]
});
</code></pre>
<p>To avoid verbosity, it is strongly suggested to always use packages that use "main" convention in their structure.</p>
<h3><a href="#multiversion" name="multiversion">Multiversion Support</a><span class="sectionMark">§ 4.2</span></h3>
<p>As mentioned in <a href="#config">Configuration Options</a>, multiple versions of a module can be loaded in a page by using different "context" configuration options. require.config() returns a require function that will use the context configuration. Here is an example that loads two different versions of the alpha and beta modules (this example is taken from one of the test files):</p>
<pre><code><script src="../require.js"></script>
<script>
var reqOne = require.config({
context: "version1",
baseUrl: "version1"
});
reqOne(["require", "alpha", "beta",],
function(require, alpha, beta) {
log("alpha version is: " + alpha.version); //prints 1
log("beta version is: " + beta.version); //prints 1
setTimeout(function() {
require(["omega"],
function(omega) {
log("version1 omega loaded with version: " +
omega.version); //prints 1
}
);
}, 100);
});
var reqTwo = require.config({
context: "version2",
baseUrl: "version2"
});
reqTwo(["require", "alpha", "beta"],
function(require, alpha, beta) {
log("alpha version is: " + alpha.version); //prints 2
log("beta version is: " + beta.version); //prints 2
setTimeout(function() {
require(["omega"],
function(omega) {
log("version2 omega loaded with version: " +
omega.version); //prints 2
}
);
}, 100);
});
</script>
</code></pre>
<p>Note that "require" is specified as a dependency for the module. This allows the require() function that is passed to the function callback to use the right context to load the modules correctly for multiversion support. If "require" is not specified as a dependency, then there will likely be an error.</p>
<h3><a href="#afterload" name="afterload">Loading Code After Page Load</a><span class="sectionMark">§ 4.3</span></h3>
<p>The example above in the <strong>Multiversion Support</strong> section shows how code can later be loaded by nested require() calls. </p>
<h3><a href="#webworker" name="webworker">Web Worker Support</a><span class="sectionMark">§ 4.4</span></h3>
<p>As of release 0.12, RequireJS can be run inside a Web Worker. Just use importScripts() inside a web worker to load require.js (or the JS file that contains the require() definition), then call require.</p>
<p>You will likely need to set the <strong>baseUrl</strong> <a href="#config">configuration option</a> to make sure require() can find the scripts to load.</p>
<p>You can see an example of its use by looking at one of the files used in <a href="https://github.com/requirejs/requirejs/blob/master/tests/workers.js">the unit test</a>.</p>
<h3><a href="#rhino" name="rhino">Rhino Support</a><span class="sectionMark">§ 4.5</span></h3>
<p>RequireJS can be used in Rhino via the <a href="download.html#rjs">r.js adapter</a>.
See <a href="https://github.com/requirejs/r.js/blob/master/README.md">the r.js README</a> for more information.</p>
<h3><a href="#nashorn" name="nashorn">Nashorn Support</a><span class="sectionMark">§ 4.6</span></h3>
<p>As of RequireJS 2.1.16, RequireJS can be used in <a href="http://www.oracle.com/technetwork/articles/java/jf14-nashorn-2126515.html">Nashorn</a>, Java 8+'s JavaScript engine, via the <a href="download.html#rjs">r.js adapter</a>.
See <a href="https://github.com/requirejs/r.js/blob/master/README.md">the r.js README</a> for more information.</p>
<h3><a href="#errors" name="errors">Handling Errors</a><span class="sectionMark">§ 4.7</span></h3>
<p>The general class of errors are 404s for scripts (not found), network timeouts or errors in the scripts that are loaded. RequireJS has a few tools to deal with them: require-specific errbacks, a "paths" array config, and a global requirejs.onError.</p>
<p>The error object passed to errbacks and the global requirejs.onError function will usually contain two custom properties:</p>
<ul>
<li><strong>requireType</strong>: A string value with a general classification, like "timeout", "nodefine", "scripterror".</li>
<li><strong>requireModules</strong>: an array of module names/URLs that timed out.</li>
</ul>
<p>If you get an error with a requireModules, it probably means other modules that depend on the modules in that requireModules array are not defined.</p>
<h4>
<a href="#ieloadfail" name="ieloadfail">Catching load failures in IE</a>
<span class="sectionMark">§ 4.6.1</span>
</h4>
<p>Internet Explorer has a set of problems that make it difficult to detect load failures for errbacks/paths fallbacks:</p>
<ul>
<li>script.onerror does not work in IE 6-8. There is no way to know if loading a script generates a 404, worse, it triggers the onreadystatechange with a complete state even in a 404 case.</li>
<li>script.onerror does work in IE 9+, but it has a bug where it does not fire script.onload event handlers right after execution of script, so it cannot support the standard method of allowing anonymous AMD modules. So script.onreadystatechange is still used. However, onreadystatechange fires with a complete state before the script.onerror function fires.</li>
</ul>
<p>So it is very difficult with IE to allow both anonymous AMD modules, which are a core benefit of AMD modules, and reliable detect errors.</p>
<p>However, if you are in a project that you know uses define() to declare all of its modules, or it uses the <a href="#config-shim">shim</a> config to specify string exports for anything that does not use define(), then if you set the <a href="#config-enforceDefine">enforceDefine</a> config value to true, the loader can confirm if a script load by checking for the define() call or the existence of the shim's exports global value.</p>
<p>So if you want to support Internet Explorer, catch load errors, and have modular code either through direct define() calls or shim config, always set <b>enforceDefine</b> to be true. See the next section for an example.</p>
<p><b>NOTE</b>: If you do set enforceDefine: true, and you use data-main="" to load your main JS module, then that main JS module <b>must call define()</b> instead of require() to load the code it needs. The main JS module can still call require/requirejs to set config values, but for loading modules it should use define().</p>
<p>If you then also use <a href="https://github.com/requirejs/almond">almond</a> to build your code without require.js, be sure to use the <a href="https://github.com/requirejs/r.js/blob/master/build/example.build.js#L413">insertRequire</a> build setting to insert a require call for the main module -- that serves the same purpose of the initial require() call that data-main does.</p>
<h4>
<a href="#errbacks" name="errbacks">require([]) errbacks</a>
<span class="sectionMark">§ 4.6.2</span>
</h4>
<p>Errbacks, when used with <a href="#undef">requirejs.undef()</a>, will allow you to detect if a module fails to load, undefine
that module, reset the config to a another location, then try again.</p>
<p>A common use case for this is to use a CDN-hosted version of a library, but if
that fails, switch to loading the file locally:</p>
<pre><code>requirejs.config({
enforceDefine: true,
paths: {
jquery: 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min'
}
});
//Later
require(['jquery'], function ($) {
//Do something with $ here
}, function (err) {
//The errback, error callback
//The error has a list of modules that failed
var failedId = err.requireModules && err.requireModules[0];
if (failedId === 'jquery') {
//undef is function only on the global requirejs object.
//Use it to clear internal knowledge of jQuery. Any modules
//that were dependent on jQuery and in the middle of loading
//will not be loaded yet, they will wait until a valid jQuery
//does load.
requirejs.undef(failedId);
//Set the path to jQuery to local path
requirejs.config({
paths: {
jquery: 'local/jquery'
}
});
//Try again. Note that the above require callback
//with the "Do something with $ here" comment will
//be called if this new attempt to load jQuery succeeds.
require(['jquery'], function () {});
} else {
//Some other error. Maybe show message to the user.
}
});
</code></pre>
<p>With `requirejs.undef()`, if you later set up a different config and try to
load the same module, the loader will still remember which modules needed
that dependency and finish loading them when the newly configured module loads.</p>
<p><b>Note</b>: errbacks only work with callback-style require calls, not define()
calls. define() is only for declaring modules.</p>
<h4>
<a href="#pathsfallbacks" name="pathsfallbacks">paths config fallbacks</a>
<span class="sectionMark">§ 4.6.3</span>
</h4>
<p>The above pattern for detecting a load failure, undef()ing a module, modifying paths and reloading is a common enough request that there is also a shorthand for it. The paths config allows array values:</p>
<pre><code>requirejs.config({
//To get timely, correct error triggers in IE, force a define/shim exports check.
enforceDefine: true,
paths: {
jquery: [
'http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min',
//If the CDN location fails, load from this location
'lib/jquery'
]
}
});
//Later
require(['jquery'], function ($) {
});
</code></pre>
<p>This above code will try the CDN location, but if that fails, fall back to the local lib/jquery.js location.</p>
<p><b>Note</b>: paths fallbacks only work for exact module ID matches. This is
different from normal paths config which can apply to any part of a module ID
prefix segment. Fallbacks are targeted more for unusual error recovery, not
a generic path search path solution, since those are inefficient in the browser.</p>
<h4>
<a href="#requirejsonerror" name="requirejsonerror">Global requirejs.onError function</a>
<span class="sectionMark">§ 4.6.4</span>
</h4>
<p>To detect errors that are not caught by local errbacks, you can override requirejs.onError():</p>
<pre><code>requirejs.onError = function (err) {
console.log(err.requireType);
if (err.requireType === 'timeout') {
console.log('modules: ' + err.requireModules);
}
throw err;
};
</code></pre>
</div>
<div class="section">
<h2>
<a href="#plugins" name="plugins">Loader Plugins</a>
<span class="sectionMark">§ 5</span>
</h2>
<p>RequireJS supports <a href="plugins.html">loader plugins</a>. This is a way to support dependencies that are not plain JS files, but are still important for a script to have loaded before it can do its work. The RequireJS wiki has <a href="https://github.com/requirejs/requirejs/wiki/Plugins">a list of plugins</a>. This section talks about some specific plugins that are maintained alongside RequireJS:</p>
<h3><a href="#text" name="text">Specify a Text File Dependency</a><span class="sectionMark">§ 5.1</span></h3>
<p>It is nice to build HTML using regular HTML tags, instead of building up DOM structures in script. However, there is no good way to embed HTML in a JavaScript file. The best that can be done is using a string of HTML, but that can be hard to manage, particularly for multi-line HTML.</p>
<p>RequireJS has a plugin, text.js, that can help with this issue. It will automatically be loaded if the text! prefix is used for a dependency. See the
<a href="https://github.com/requirejs/text">text.js README</a> for more information.</p>
<h3><a href="#pageload" name="pageload">Page Load Event Support/DOM Ready</a><span class="sectionMark">§ 5.2</span></h3>
<p>It is possible when using RequireJS to load scripts quickly enough that they complete before the DOM is ready. Any work that tries to interact with the DOM should wait for the DOM to be ready. For modern browsers, this is done by waiting for the DOMContentLoaded event.</p>
<p>However, not all browsers in use support DOMContentLoaded. The domReady module implements a cross-browser method to determine when the DOM is ready. <a href="download.html#domReady">Download the module</a> and use it in your project like so:</p>
<pre><code>require(['domReady'], function (domReady) {
domReady(function () {
//This function is called once the DOM is ready.
//It will be safe to query the DOM and manipulate
//DOM nodes in this function.
});
});
</code></pre>
<p>Since DOM ready is a common application need, ideally the nested functions
in the API above could be avoided. The domReady module also implements the <a href="plugins.html">Loader Plugin API</a>,
so you can use the loader plugin syntax (notice the <b>!</b> in the domReady dependency) to force the
require() callback function to wait for the DOM to be ready before executing. <pre>domReady</pre> will return
the current document when used as a loader plugin:</p>
<pre><code>require(['domReady!'], function (doc) {
//This function is called once the DOM is ready,
//notice the value for 'domReady!' is the current
//document.
});
</code></pre>
<p><b>Note:</b> If the document takes a while to load (maybe it is a very large document, or has HTML script tags loading large JS files that block DOM completion until they are done), using domReady as a loader plugin may result in a RequireJS "timeout" error. If this is a problem either increase the <a href="#config-waitSeconds">waitSeconds</a> configuration, or just use domReady as a module and
call domReady() inside the require() callback.</p>
<h3><a href="#i18n" name="i18n">Define an I18N Bundle</a><span class="sectionMark">§ 5.3</span></h3>
<p>Once your web app gets to a certain size and popularity, localizing the strings in the interface and providing other locale-specific information becomes more useful. However, it can be cumbersome to work out a scheme that scales well for supporting multiple locales.</p>
<p>RequireJS allows you to set up a basic module that has localized information without forcing you to provide all locale-specific information up front. It can be added over time, and only strings/values that change between locales can be defined in the locale-specific file.</p>
<p>i18n bundle support is provided by the i18n.js plugin. It is automatically loaded when a module or dependency specifies the i18n! prefix (more info below). <a href="download.html#i18n">Download the plugin</a> and put it in the same directory as your app's main JS file.</p>
<p>To define a bundle, put it in a directory called "nls" -- the i18n! plugin assumes a module name with "nls" in it indicates an i18n bundle. The "nls" marker in the name tells the i18n plugin where to expect the locale directories (they should be immediate children of the nls directory). If you wanted to provide a bundle of color names in your "my" set of modules, create the directory structure like so:</p>
<ul>
<li>my/nls/colors.js</li>
</ul>
<p>The contents of that file should look like so:</p>
<pre><code>//my/nls/colors.js contents:
define({
"root": {
"red": "red",
"blue": "blue",
"green": "green"
}
});
</code></pre>
<p>An object literal with a property of "root" defines this module. That is all you have to do to set the stage for later localization work.</p>
<p>You can then use the above module in another module, say, in a my/lamps.js file:</p>
<pre><code>//Contents of my/lamps.js
define(["i18n!my/nls/colors"], function(colors) {
return {
testMessage: "The name for red in this locale is: " + colors.red
}
});
</code></pre>
<p>The my/lamps module has one property called "testMessage" that uses colors.red to show the localized value for the color red.</p>
<p>Later, when you want to add a specific translation to a file, say for the fr-fr locale, change my/nls/colors to look like so:</p>
<pre><code>//Contents of my/nls/colors.js
define({
"root": {
"red": "red",
"blue": "blue",
"green": "green"
},
"fr-fr": true
});
</code></pre>
<p>Then define a file at my/nls/fr-fr/colors.js that has the following contents:</p>
<pre><code>//Contents of my/nls/fr-fr/colors.js
define({
"red": "rouge",
"blue": "bleu",
"green": "vert"
});
</code></pre>
<p>RequireJS will use the browser's navigator.languages, navigator.language or navigator.userLanguage property to determine what locale values to use for my/nls/colors, so your app does not have to change. If you prefer to set the locale, you can use the <a href="#config-moduleconfig">module config</a> to pass the locale to the plugin:</p>
<pre><code>requirejs.config({
config: {
//Set the config for the i18n
//module ID
i18n: {
locale: 'fr-fr'
}
}
});
</code></pre>
<p><strong>Note</strong> that RequireJS will always use a lowercase version of the locale, to avoid case issues, so all of the directories and files on disk for i18n bundles should use lowercase locales.</p>
<p>RequireJS is also smart enough to pick the right locale bundle, the one that most closely matches the ones provided by my/nls/colors. For instance, if the locale is "en-us", then the "root" bundle will be used. If the locale is "fr-fr-paris" then the "fr-fr" bundle will be used.</p>
<p>RequireJS also combines bundles together, so for instance, if the french bundle was defined like so (omitting a value for red):</p>
<pre><code>//Contents of my/nls/fr-fr/colors.js
define({
"blue": "bleu",
"green": "vert"
});
</code></pre>
<p>Then the value for red in "root" will be used. This works for all locale pieces. If all the bundles listed below were defined, then RequireJS will use the values in the following priority order (the one at the top takes the most precedence):</p>
<ul>
<li>my/nls/fr-fr-paris/colors.js</li>
<li>my/nls/fr-fr/colors.js</li>
<li>my/nls/fr/colors.js</li>
<li>my/nls/colors.js</li>
</ul>
<p>If you prefer to not include the root bundle in the top level module, you can define it like a normal locale bundle. In that case, the top level module would look like:</p>
<pre><code>//my/nls/colors.js contents:
define({
"root": true,
"fr-fr": true,
"fr-fr-paris": true
});
</code></pre>
<p>and the root bundle would look like:</p>
<pre><code>//Contents of my/nls/root/colors.js
define({
"red": "red",
"blue": "blue",
"green": "green"
});
</code></pre>
</div>
================================================
FILE: docs/commonjs.html
================================================
<div id="directory" class="section">
<h1>CommonJS Notes</h1>
<ul class="index mono">
<li class="hbox"><a href="#intro">Introduction</a><span class="spacer boxFlex"></span><span class="sect">§ 1</span></li>
<li class="hbox"><a href="#manualconversion">Manual Conversion</a><span class="spacer boxFlex"></span><span class="sect">§ 2</span></li>
<li class="hbox"><a href="#autoconversion">Conversion Tool</a><span class="spacer boxFlex"></span><span class="sect">§ 3</span></li>
<li class="hbox"><a href="#exports">Setting Exported Value</a><span class="spacer boxFlex"></span><span class="sect">§ 4</span></li>
<li class="hbox"><a href="#altsyntax">Alternative Syntax</a><span class="spacer boxFlex"></span><span class="sect">§ 5</span></li>
<li class="hbox"><a href="#packages">Loading Modules from CommonJS Packages</a><span class="spacer boxFlex"></span><span class="sect">§ 6</span></li>
<li class="hbox"><a href="#optimize">Optimization Tool</a><span class="spacer boxFlex"></span><span class="sect">§ 7</span></li>
</ul>
</div>
<div class="section">
<h2><a name="intro">Introduction</a><span class="sectionMark">§ 1</span></h2>
<p><a href="http://www.commonjs.org/">CommonJS</a> defines <a href="http://wiki.commonjs.org/wiki/Modules/1.1.1">a module format</a>. Unfortunately, it was defined without giving browsers equal footing to other JavaScript environments. Because of that, there are CommonJS spec proposals for <a href="http://wiki.commonjs.org/wiki/Modules/Transport">Transport formats</a> and an <a href="http://wiki.commonjs.org/wiki/Modules/Async/A">asynchronous require</a>.</p>
<p>RequireJS tries to keep with the spirit of CommonJS, with using string names to refer to dependencies, and to avoid modules defining global objects, but still allow coding a module format that works well natively in the browser. RequireJS implements the <a href="http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition">Asynchronous Module Definition</a> (formerly Transport/C) proposal.</p>
<p>If you have modules that are in the traditional CommonJS module format, then you can easily convert them to work with RequireJS. Not all modules will convert cleanly to the new format. Types of modules that may not convert well:</p>
<ul>
<li>Modules that use conditional code to do a require call, like if(someCondition) require('a1') else require('a2');</li>
<li>Some types of circular dependencies.</li>
</div>
<div class="section">
<h2><a name="manualconversion">Manual Conversion</a><span class="sectionMark">§ 2</span></h2>
<p>If you just have a few modules to convert, then all you need to do is wrap the module in this code:</p>
<pre><code>define(function(require, exports, module) {
//Put traditional CommonJS module content here
});
</code></pre>
<p><strong>IMPORTANT</strong>: The function arguments should always be listed as <strong>require, exports, module</strong>, with those exact names and in that exact order, otherwise chaos will ensue. You can leave off exports and module from the list, but if they are needed, they need to be specified in the exact order illustrated here.</p>
</div>
<div class="section">
<h2><a name="autoconversion">Conversion Tool</a><span class="sectionMark">§ 3</span></h2>
<p>If you have many modules to convert, the <a href="https://github.com/requirejs/r.js">r.js project</a> has a converter tool built into the r.js file. Give it the path to the directory you want to convert and an output directory:</p>
<pre><code>node r.js -convert path/to/commonjs/modules/ path/to/output
</code></pre>
<p>There are a small number of CommonJS modules do not work well as
define()-wrapped modules. See the <a href="https://github.com/requirejs/r.js">r.js README</p> for more
information.</p>
</div>
<div class="section">
<h2><a name="exports">Setting Exported Value</a><span class="sectionMark">§ 4</span></h2>
<p>There are some CommonJS systems, mainly Node, that allow setting the exported value by assigning the exported value as module.exports. That idiom is supported by RequireJS, but there is another, easier way -- just return the value from the function passed to <strong>define</strong>:</p>
<pre><code>define(function (require) {
var foo = require('foo');
//Define this module as exporting a function
return function () {
foo.doSomething();
};
});
</code></pre>
<p>With this approach, then you normally do not need the exports and module function arguments, so you can leave them off the module definition.</p>
</div>
<div class="section">
<h2><a name="altsyntax">Alternative Syntax</a><span class="sectionMark">§ 5</span></h2>
<p>Instead of using require() to get dependencies inside the function passed to define(), you can also specify them via a dependency array argument to define(). The order of the names in the dependency array match the order of arguments passed to the definition function passed to define(). So the above example that uses the module <strong>foo</strong>:</p>
<pre><code>define(['foo'], function (foo) {
return function () {
foo.doSomething();
};
});
</code></pre>
<p>See the <a href="api.html">API docs</a> for more information on that syntax.</p>
</div>
<div class="section">
<h2><a name="packages">Loading Modules from CommonJS Packages</a><span class="sectionMark">§ 6</span></h2>
<p>Modules in CommonJS packages can be loaded by RequireJS by setting up the RequireJS configuration to know about the location and package attributes. See the <a href="api.html#packages">packages API section</a> for more information.</p>
</div>
<div class="section">
<h2><a name="optimize">Optimization Tool</a><span class="sectionMark">§ 7</span></h2>
<p>RequireJS has an optimization tool that can combine module definitions together into optimized bundles for browser delivery. It works as a command-line tool that you use as part of code deployment. See the <a href="optimization.html">optimization docs</a> for more information.</p>
</div>
================================================
FILE: docs/contributing.html
================================================
<div id="directory" class="section">
<h1>Contributing to RequireJS</h1>
<ul class="index mono">
<li class="hbox"><a href="#whycla">Why a CLA?</a><span class="spacer boxFlex"></span><span class="sect">§ 1</span></li>
<li class="hbox"><a href="#codestyle">Code style</a><span class="spacer boxFlex"></span><span class="sect">§ 2</span></li>
</ul>
<span class="note">Note: <a href="https://github.com/requirejs/requirejs">The source for RequireJS is available on GitHub</a></span>
<p>For something that is bigger than a one or two line fix:</p>
<ol style="color:#222;">
<li><a href="https://help.github.com/forking/">Create your own fork of the code</a></li>
<li>Do the changes in your fork</li>
<li>If you like the change and think the project could use it:
<ol style="color:#222;list-style-type:disc;">
<li>Be sure you have followed <a href="#codestyle">the code style for the project</a>.</li>
<li>Sign the <a href="https://contribute.jquery.org/CLA/">Contributor License Agreement, CLA, with the jQuery Foundation</a>.</li>
<li>Note the <a href="https://jquery.org/conduct/">jQuery Foundation Code of Conduct</a>.</li>
<li>Send a pull request indicating that you have a CLA on file.</li>
</ol></li>
</ol>
<p>For one or two line fixes, you can use the <a href="https://github.com/requirejs/requirejs/issues">RequireJS GitHub Issues page</a> to indicate the problem. You can also do the full fork/pull request as mentioned above, but a CLA is not needed for one or two line fixes.</p>
</div>
<div class="section">
<h2><a name="whycla">Why a CLA?</a><span class="sectionMark">§ 1</span></h2>
<p>CLAs are common with open source projects, with the Apache projects probably being the most well known. The goal is to allow RequireJS to be used in as many projects as possible, and for some companies, using only CLA-approved code is the best option.</p>
<p>You still own the copyright on your contribution, the CLA just gives the most flexibility for licensing, and assures the lineage of the intellectual property. You should only submit patches for your own intellectual property, and not the intellectual property of others.</p>
<p>Additional reading that may be helpful:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Contributor_License_Agreement">Wikipedia on CLAs</a></li>
</ul>
</div>
<div class="section">
<h2><a name="codestyle">Code Style</a><span class="sectionMark">§ 2</span></h2>
<p><a href="http://jslint.com/">JSLint</a> is used for checking code style. It is also useful for avoiding some errors. The default settings on JSLint should be fine to use, in particular, 4 spaces for indentation, do not use tabs.</p>
<p>camelCase should be used for all variables and file names. Avoid the use of underscores as word separators. This extends to things like CSS class names, IDs in test HTML documents, everything.</p>
<p>Some exceptions to JSLint can be indicated at the top of each JS file, but they should be avoided when possible. Two common exceptions you may see in the source:</p>
<ul>
<li><strong>nomen: false</strong>, allow underscore at the beginning of some property/variable/function names.</li>
<li><strong>plusplus: false</strong>, but only to allow for loops with an incrementing ++ value. Other uses of ++ should be avoided.</li>
</ul>
</div>
================================================
FILE: docs/design/packages.md
================================================
# Packages
Moved to [pkg project](https://github.com/requirejs/pkg/blob/master/docs/design/packages.md)
================================================
FILE: docs/dojo.html
================================================
<div id="directory" class="section">
<h1>How to use RequireJS with Dojo</h1>
<p>As of Dojo 1.8, Dojo has converted their modules to AMD modules. However, Dojo uses some loader plugins, and the loader plugin APIs are still in draft mode for AMD. So while some modules from Dojo can be used with RequireJS, it will be difficult to use all of Dojo. It is best to use Dojo's AMD loader until <a href="http://bugs.dojotoolkit.org/ticket/15616">ticket 15616</a> has been resolved.</p>
</div>
<div class="section"></div>
================================================
FILE: docs/download.html
================================================
<div id="directory" class="section">
<h1>Download RequireJS</h1>
<ul class="index mono">
<li class="hbox"><a href="#latest">Latest Release</a><span class="spacer boxFlex"></span><span class="sect">§ 1</span></li>
<ul>
<li class="hbox"><a href="#requirejs">require.js</a><span class="spacer boxFlex"></span><span class="sect">§ 1.1</span></li>
<li class="hbox"><a href="#rjs">r.js: Optimizer and Node/Rhino/xpcshell adapter</a><span class="spacer boxFlex"></span><span class="sect">§ 1.2</span></li>
</ul>
<li class="hbox"><a href="#plugins">Plugins</a><span class="spacer boxFlex"></span><span class="sect">§ 2</span></li>
<ul>
<li class="hbox"><a href="#text">text</a><span class="spacer boxFlex"></span><span class="sect">§ 2.1</span></li>
<li class="hbox"><a href="#domReady">domReady</a><span class="spacer boxFlex"></span><span class="sect">§ 2.2</span></li>
<li class="hbox"><a href="#cs">cs (CoffeeScript)</a><span class="spacer boxFlex"></span><span class="sect">§ 2.3</span></li>
<li class="hbox"><a href="#i18n">i18n</a><span class="spacer boxFlex"></span><span class="sect">§ 2.4</span></li>
</ul>
<li class="hbox"><a href="#releasenotes">Release Notes</a><span class="spacer boxFlex"></span><span class="sect">§ 3</span></li>
</ul>
</div>
<div class="section">
<h2><a name="latest">Latest Release</a><span class="sectionMark">§ 1</span></h2>
<div class="subSection">
<h4 class="hbox">
<a name="requirejs">require.js 2.3.8</a>
<span class="boxFlex"></span>
<a class="download" href="https://requirejs.org/docs/release/2.3.8/minified/require.js">Minified</a>
<a class="download" href="https://requirejs.org/docs/release/2.3.8/comments/require.js">With Comments</a>
</h4>
<p>All you need to start using require.js in the browser.</p>
</div>
<div class="subSection">
<h4 class="hbox">
<a name="rjs">r.js: Optimizer and Node/Rhino/Nashorn/xpcshell adapter</a>
<span class="boxFlex"></span>
<a class="download" href="https://requirejs.org/docs/release/2.3.8/r.js">Download</a>
</h4>
<p>The r.js file allows you to run the optimizer as well as run modules in Node, Rhino, Nashorn or xpcshell.</p>
<p>If you are running in Node, and want to use npm to install this file via npm, see the <a href="node.html">Use with Node</a> page for more information.</p>
<p>For information on its use, as well as how to get the JAR files to run it under Rhino/Nashorn, see the <a href="https://github.com/requirejs/r.js">r.js README</a>.</p>
</div>
</div>
<div class="section">
<h2><a name="plugins">Plugins</a><span class="sectionMark">§ 2</span></h2>
<p>These are useful loader plugins that have the same license terms as require.js itself. Download the plugin file and place it as a sibling to your "data-main" main.js script.</p>
<div class="subSection">
<h4 class="hbox">
<a name="text">text</a>
<span class="boxFlex"></span>
<a class="download" href="https://raw.github.com/requirejs/text/latest/text.js">Download</a>
</h4>
<p><a href="api.html#text">Load text files and treat them as dependencies</a>. Great for loading templates. The text strings can be inlined in an optimized build when the optimizer is used.</p>
</div>
<div class="subSection">
<h4 class="hbox">
<a name="domReady">domReady</a>
<span class="boxFlex"></span>
<a class="download" href="https://raw.github.com/requirejs/domReady/latest/domReady.js">Download</a>
</h4>
<p><a href="api.html#pageload">Wait for the DOM is ready</a>. Useful for pausing execution of top level application
logic until the DOM is ready for querying/modification.</p>
</div>
<div class="subSection">
<h4 class="hbox">
<a name="cs">cs (CoffeeScript)</a>
<span class="boxFlex"></span>
<a class="download" href="https://github.com/requirejs/require-cs/raw/latest/cs.js">Download</a>
</h4>
<p>Load files written in CoffeeScript. With this plugin, it is easy to code in CoffeeScript in the browser, it can participate in the optimizer optimizations, and it works in Node and Rhino/Nashorn via the <a href="#rjs">RequireJS adapter</a>. This is the best way to do cross-environment, modular CoffeeScript. <a href="https://github.com/requirejs/require-cs">The project home</a> has more information on how to install and use it.</p>
</div>
<div class="subSection">
<h4 class="hbox">
<a name="i18n">i18n</a>
<span class="boxFlex"></span>
<a class="download" href="https://raw.github.com/requirejs/i18n/latest/i18n.js">Download</a>
</h4>
<p><a href="api.html#i18n">Load string bundles</a> used in internationalization (i18n) that are made up of separate country/language/locale-specific bundles.</p>
</div>
</div>
<div class="section">
<h2><a name="releasenotes">Release Notes</a><span class="sectionMark">§ 3</span></h2>
<h3 id="2-3-8">2.3.8</h3>
<ul>
<li><a href="hhttps://github.com/requirejs/requirejs/issues/1866">proto/constructor check that works in ie6-8</a></li>
</ul>
<h3 id="2-3-7">2.3.7</h3>
<ul>
<li><a href="hhttps://github.com/requirejs/requirejs/issues/1854">Security Vulnerability: Prototype pollution</a></li>
</ul>
<h3 id="2-3-6">2.3.6</h3>
<p>Small updates to the optimizer.</p>
<ul>
<li><a href="https://github.com/requirejs/r.js/milestone/47?closed=1">Fixed r.js issues</a></li>
</ul>
<h3 id="2-3-5">2.3.5</h3>
<p>Just updates to the optimizer, mainly an update to UglifyJS 2.8.29.</p>
<ul>
<li><a href="https://github.com/requirejs/r.js/milestone/46?closed=1">Fixed r.js issues</a></li>
</ul>
<h3 id="2-3-4">2.3.4</h3>
<p><a href="https://github.com/requirejs/r.js/issues/963">Just an update to the optimizer to use Esprima 4.0.</a></p>
<h3 id="2-3-3">2.3.3</h3>
<p>Optimizer updates for esprima and uglify-js dependencies, and a fix for map config used by plugins in builds. require.js fix for calling plugin normalization more than once. <a href="https://github.com/requirejs/alameda/milestone/11?closed=1">alameda 1.1.1</a> also fixes calling plugin normalization more than once.</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/milestone/48?closed=1">Fixed requirejs issues</a></li>
<li><a href="https://github.com/requirejs/r.js/milestone/44?closed=1">Fixed r.js issues</a></li>
</ul>
<h3 id="2-3-2">2.3.2</h3>
<p>Fixes an issue that prevented the 2.3.x optimizer from running in Java's 8+'s jjs. There was a <a href="https://github.com/requirejs/requirejs/issues/1588">change in require.js</a> and a <a href="https://github.com/requirejs/r.js/issues/933">change in the r.js optimizer</a>.</p>
<h3 id="2-3-1">2.3.1</h3>
<p>Only one change from 2.3.0, and it is in the optimizer. <a href="https://github.com/requirejs/r.js/issues/929">It fixes how the bundled uglifyjs declares the addFile function</a>. Without the fix, it causes an error in Node 0.10/0.12. Newer versions of Node are not affected.</p>
<h3 id="2-3-0">2.3.0</h3>
<p>The way dependencies are found for the <a href="https://requirejs.org/docs/whyamd.html#sugar">sugared syntax</a> changed slightly in <a href="https://github.com/requirejs/requirejs/pull/1582">#1582</a>. It is now faster and should catch more legitimate dependency cases. You should not notice any negative consequences to the change, but given how important that mechanism is, it was best to rev the minor version to 2.3. The r.js optimizer also <a href="https://github.com/requirejs/r.js/issues/921">handles larger directory changes better</a>. If you are using 2.2, you are encouraged to update to 2.3.</p>
<p><a href="https://github.com/requirejs/alameda/releases/tag/1.1.0">alameda was also updated to 1.1.0</a> to include the same dependency searching change as requirejs 2.3.</p>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?q=milestone%3A2.3.0+is%3Aclosed">Fixed requirejs issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?q=milestone%3A2.3.0+is%3Aclosed">Fixed r.js issues</a></li>
</ul>
<h3 id="2-2-0">2.2.0</h3>
<p><a href="https://jrburke.com/2016/03/17/requirejs-2.2-alameda-1.0-released/">More details on the higher level motivations for the 2.2 release.</a></p>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?q=milestone%3A2.2.0+is%3Aclosed">Fixed requirejs issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?q=milestone%3A2.2.0+is%3Aclosed">Fixed r.js issues</a></li>
</ul>
<h3 id="2-1-22">2.1.22</h3>
<p>The main issue: a change in 2.1.21 of require.js created an extraneous global. While jshint is used in the repo, it was not properly configured to catch that issue, but it is now. Only the require.js loader changed. No r.js optimizer-specific bug fixes, but it uses require.js as a dependency.</p>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?q=milestone%3A2.1.22+is%3Aclosed">Fixed requirejs issues</a></li>
</ul>
<h3 id="2-1-21">2.1.21</h3>
<p>Main changes in the r.js optimizer: updates to the Esprima and UglifyJS dependencies. For require.js: fixes a couple of error conditions.</p>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?q=milestone%3A2.1.21+is%3Aclosed">Fixed requirejs issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?q=milestone%3A2.1.21+is%3Aclosed">Fixed r.js issues</a></li>
</ul>
<h3 id="2-1-20">2.1.20</h3>
<p>The main fixes: a fix in require.js to allow out of <a href="https://github.com/requirejs/requirejs/issues/1389">order define calls in a built file</a>, and an optimizer fix to <a href="https://github.com/requirejs/r.js/issues/833">detect another UMD pattern</a> and to skip looking at its internal structure.</p>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?q=milestone%3A2.1.20+is%3Aclosed">Fixed requirejs issue</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?q=milestone%3A2.1.20+is%3Aclosed">Fixed r.js issues</a></li>
</ul>
<h3 id="2-1-19">2.1.19</h3>
<p>A new <a href="https://github.com/requirejs/requirejs/pull/1364">onNodeCreated</a> hook in require.js that will allow extending requirejs to support <a href="https://w3c.github.io/webappsec/specs/subresourceintegrity/">Subresource Integrity (SRI)</a>. Updates for esprima and uglifyjs2 in the optimizer.</p>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?q=milestone%3A2.1.19+is%3Aclosed">Fixed requirejs issue</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?q=milestone%3A2.1.19+is%3Aclosed">Fixed r.js issues</a></li>
</ul>
<h3 id="2-1-18">2.1.18</h3>
<p>The notable changes are in the r.js optimizer:</p>
<ul>
<li>An update to Esprima 2.2.0 for dependency tracing. Helps properly parse modules that are using some ES2015 features, like template strings.</li>
<li>A fix for detecting when a script exports an publicly visible AMD API and should be hoisted in the built output. The new detection is a bit stricter than before, so if your script with the public AMD API is not hoisted, please open a <a href="https://github.com/requirejs/r.js/issues">r.js issue</a>.</li>
</ul>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?q=milestone%3A2.1.18+is%3Aclosed">Fixed requirejs issue</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?q=milestone%3A2.1.18+is%3Aclosed">Fixed r.js issues</a></li>
</ul>
<h3 id="2-1-17">2.1.17</h3>
<p>The notable changes are in the r.js optimizer: an update to Esprima 2.1.0 for dependency tracing, and a fix around "use strict" processing that should help some loader plugins or build scenarios that were using React.</p>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?q=milestone%3A2.1.17+is%3Aclosed">Fixed requirejs issue</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?q=milestone%3A2.1.17+is%3Aclosed">Fixed r.js issues</a></li>
</ul>
<h3 id="2-1-16">2.1.16</h3>
<p>The notable changes are in the r.js optimizer:</p>
<ul>
<li><a href="http://esprima.org/">Esprima 2.0</a> is used by the optimizer when parsing modules for dependencies. This allows some ES6 features to be used. Whatever is parsable by Esprima 2.0 is what is supported (when running in xpcshell, <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Parser_API">Reflect.parse</a> is still used).</li>
<li><a href="https://github.com/requirejs/r.js#nashorn">The r.js optimizer runs in Nashorn now</a>.</li>
<li>Expanded support of some UMD-wrapped files that start with <code>!function(a) {...`</code>. If you use the <a href="https://github.com/ForbesLindesay/umd">UMD node package</a> to generate your UMD wrappers, upgrade to umd@3.0.0 or later to get full compatibility with the r.js optimizer.</li>
</ul>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?q=milestone%3A2.1.16+is%3Aclosed">Fixed requirejs issue</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?q=milestone%3A2.1.16+is%3Aclosed">Fixed r.js issues</a></li>
</ul>
<h3 id="2-1-15">2.1.15</h3>
<p>Mainly fixes a regression from 2.1.14 in the r.js optimizer where <a href="https://github.com/requirejs/r.js/issues/704">some define() calls were not found</a>. The most common manifestations of the bug would be either an extra <code>define('jquery', function(){})</code> in the build output or namespaced builds not working. The fixes for 2.1.15 are just in the optimizer. Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/r.js/issues?q=milestone%3A2.1.15+is%3Aclosed">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-1-14">2.1.14</h3>
<p>A couple more regression fixes for 2.1.12. One to <a href="https://github.com/requirejs/requirejs/issues/1131">fix nested plugin ID normalization</a>, like "pluginA!pluginbB!resource", and one for the <a href="https://github.com/requirejs/requirejs/issues/1133">optimizer incorrectly detecting UMD wrapped code</a>.</p>
<h3 id="2-1-13">2.1.13</h3>
<p>Version 2.1.12 regressed around ID normalization. <a href="https://github.com/requirejs/requirejs/issues/1129">2.1.13 fixes that regression</a>, and it is recommended that you do not use 2.1.12, but use 2.1.13 instead.</p>
<h3 id="2-1-12">2.1.12</h3>
<p>Just a bug fix/maintenance release. Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=34&page=1&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?milestone=31&page=1&state=closed">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-1-11">2.1.11</h3>
<p>Some bug fixes, with the most notable addition is an optimizer option, <code>wrapShim</code>. This will wrap shimmed dependencies in a define() call so that they work better after a build when their upstream dependencies are also AMD modules with dependencies.</p>
<p>The most notable case is probably when using an AMD-aware version of Backbone, but using shim config for scripts that depend on Backbone. If this is your use case, then setting <code>wrapShim: true</code> in the optimizer config will likely fix any post-build problem you might see. More details in <a href="https://github.com/requirejs/r.js/issues/623">the bug ticket</a>.
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=33&page=1&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?milestone=30&page=1&state=closed">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-1-10">2.1.10</h3>
<p>Mainly a maintenance release, and improves some cases when reusing code that was installed via npm. There are two new config options for the loader too:</p>
<ul>
<li><a href="api.html#config-nodeIdCompat">nodeIdCompat</a>: some node modules installed by npm use module IDs like <code>example.js</code> and <code>example</code> interchangeably. Setting this config option to true will accommodate that style. <a href="https://github.com/requirejs/almond">almond</a> 0.2.9+ also supports this option.</li>
<li><a href="api.html#config-bundles">bundles</a>: a more compact way to list a set of module IDs belonging to a bundle ID, and supports loader plugin resource IDs.</li>
</ul>
<p>And for the optimizer, the <a href="optimization.html#mainConfigFile">mainConfigFile</a> option can now take an array of file paths that have configs in them. Later values take precedent over earlier values.</p>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=32&page=1&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?milestone=29&page=1&state=closed">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-1-9">2.1.9</h3>
<p>Full list of changes:</p>
<p>Mainly a maintenance release to fix bugs. There is a new <a href="api.html#config-skipDataMain">skipDataMain</a> option in require.js to avoid the data-main work, which can be useful for browser extensions that should let the main content page's requirejs handle the data-main.</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=31&page=1&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?milestone=28&page=1&state=closed">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-1-8">2.1.8</h3>
<p>A small release to fix an optimizer issue with <a href="https://github.com/requirejs/r.js/issues/476">parsing config calls for modifications</a>.</p>
<h3 id="2-1-7">2.1.7</h3>
<p>The main changes for this release:</p>
<ul>
<li>For xpcshell, the optimizer uses the built in Reflect parser API instead of Esprima. xpcshell, on Linux and Windows in particular, has a constrained stack, and normal Esprima use was not possible. To accommodate this change, some of the parsing approaches used internally by r.js moved away from token scanning to tree walking. The only visible output change you may see is different use of space characters in transformed code.</li>
<li>The source map support was updated to use the new //# syntax as specified by the spec. This change is still making its way through the browsers, so if you need source map or sourceURL support with 2.1.7, you may need to use Firefox Aurora or Chrome Canary channels. The browser support levels should get better in around six weeks time.</li>
</ul>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?direction=desc&milestone=28&page=1&sort=created&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?milestone=26&page=1&state=closed">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-1-6">2.1.6</h3>
<p><a href="optimization.html#sourcemaps">Source map support</a> has been expanded. Previously, it was just supported for going from minified, bundled code to the unminified, bundled code. If <code>optimize: 'uglify2'</code> is used, it will now go back to the separated, unbundled files.</p>
<p>Source map support is still considered experimental though, so you may find bugs. If you find one, file an <a href="https://github.com/requirejs/r.js/issues">r.js issue</a>, ideally with a test case.</p>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?direction=desc&milestone=27&page=1&sort=created&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?milestone=25&page=1&state=closed">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-1-5">2.1.5</h3>
<p>Biggest change is support for running the optimizer and loading AMD modules in
<a href="https://developer.mozilla.org/en-US/docs/XPConnect/xpcshell">xpcshell</a>. Other than that,
just a maintenance release.</p>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?direction=desc&milestone=26&sort=created&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?milestone=23&state=closed">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-1-4">2.1.4</h3>
<p>Quick release for a bug that slipped in the 2.1.3 release in the r.js optimizer.
So even though require.js now has a 2.1.4 version, it is the same as 2.1.3,
and the optimizer is the same as 2.1.3 except for this one fix:</p>
<ul>
<li><a href="https://github.com/requirejs/r.js/issues/356">Bug 356</a>: cssPrefix normalization always needs to happen</li>
</ul>
<p>Without this fix, in some cases 2.1.3 would insert "undefined" in some
optimized CSS files, making them unusable.</p>
<h3 id="2-1-3">2.1.3</h3>
<p>Maintenance release. A change that may be noticeable:</p>
<p><a href="https://requirejs.org/docs/api.html#modulenotes-urls">require.toUrl()</a>
now correctly generates URLs for string values passed to it without an
extension. Previous versions of toUrl() would append a
".js" extension automatically. If you relied on that behavior, when you
update to 2.1.3, then you may need to do a code change to append the .js
extension yourself:</p>
<pre><code>require.toUrl('some/value') + '.js'</code></pre>
<p>The text plugin has been updated to also work with this change, so if you want
to generate non-extension paths for text resources, be sure to upgrade to
to the <a href="https://raw.github.com/requirejs/text/latest/text.js">2.0.4 version of text.js</a>.</p>
<p>Normal use of toUrl with a value that has an extension continues to work the same.</p>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?direction=desc&milestone=24&page=1&sort=created&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=21">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-1-2">2.1.2</h3>
<p>The big changes for this release are in the optimizer:</p>
<ul>
<li>The optimizer can now <a href="optimization.html#requirements">run in the browser</a>, to enable web-based custom builds of your library.</li>
<li>"uglify2" is an allowed "optimize" value now, using UglifyJS 2.1.11.</li>
<li>Experimental support for <a href="optimization.html#sourcemaps">source maps</a>.</li>
<li>The optimizer runs faster now, and has some <a href="optimization.html#turbo">speed options</a>.</li>
</ul>
<p>Full list of changes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=22&sort=created&direction=desc&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=20">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-1-1">2.1.1</h3>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=21&sort=created&direction=desc&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=19">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-1-0">2.1.0</h3>
<p>See the <a href="https://github.com/requirejs/requirejs/wiki/Upgrading-to-RequireJS-2.1">Upgrading to 2.1 page</a>.
<h3 id="2-0-6">2.0.6</h3>
<p>The main focus of this release was cleaning up some rough edges after switching to esprima for all module parsing. Most notably, findNestedDependencies should work correctly again. The bundled UglifyJS was updated to 1.3.3 too.</p>
<p>Complete list of fixes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=20&sort=created&direction=desc&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=18">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-0-5">2.0.5</h3>
<p>Probably the most notable changes:</p>
<ul>
<li>require.js: fix for <a href="https://github.com/requirejs/requirejs/issues/392">a 'use strict' issue in Safari 6</a>: should only show up in certain non-optimized scenarios.</li>
<li>r.js optimizer: changed over to <a href="http://esprima.org/">esprima</a> for all dependency tracing. This set the stage for allowing some forms of <a href="https://github.com/requirejs/r.js/issues/72">JavaScript 1.8 to be optimized</a>, with the
help of some regexps.</li>
</ul>
<p>Complete list of fixes:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=19&sort=created&direction=desc&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=17">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-0-4">2.0.4</h3>
<p>Same as 2.0.3, but rolled back a change in r.js that caused a logging error.</p>
<ul>
<li><a href="https://github.com/requirejs/r.js/issues/225">Fixed r.js logging rollback</a></li>
</ul>
<h3 id="2-0-3">2.0.3</h3>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=17&sort=created&direction=desc&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=15">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-0-2">2.0.2</h3>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=16&sort=created&direction=desc&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=14">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-0-1">2.0.1</h3>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=15&sort=created&direction=desc&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=13">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="2-0-0">2.0.0</h3>
<ul>
<li><a href="https://github.com/requirejs/requirejs/wiki/Upgrading-to-RequireJS-2.0">2.0 changes</a></li>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=13&sort=created&direction=desc&state=closed">Fixed require.js issues</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=10">Fixed r.js optimizer issues</a></li>
</ul>
<h3 id="1-0-8">1.0.8</h3>
<p>Small bug fixes to:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=12&sort=created&direction=desc&state=closed">require.js</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=9">r.js optimizer</a></li>
</ul>
<h3 id="1-0-7">1.0.7</h3>
<p>Small bug fixes to:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=11&sort=created&direction=desc&state=closed">require.js</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=8">r.js optimizer</a></li>
</ul>
<h3 id="1-0-6">1.0.6</h3>
<p>Main purpose of the release is to fix a regression in 1.0.5 where the
optimizer's "dir" config option was not applied correctly when passed on the
command line.</p>
<p>The other notable change: the optimizer now supports
<a href="https://github.com/requirejs/r.js/blob/master/build/example.build.js#L320">onBuildRead
and onBuildWrite</a> functions that are called when JS modules are read or written
for an optimized build layer. This allows doing some regexp work to modify their
contents.</p>
<p>Small bug fixes to:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=10&sort=created&direction=desc&state=closed">require.js</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=7">r.js optimizer</a></li>
</ul>
<h3 id="1-0-5">1.0.5</h3>
<p>Small bug fixes to:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=8&sort=created&direction=desc&state=closed">require.js</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=6">r.js optimizer</a></li>
</ul>
<h3 id="1-0-4">1.0.4</h3>
<p>Small bug fixes to:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=7&sort=created&direction=desc&state=closed">require.js</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?milestone=5&sort=created&direction=desc&state=closed">r.js optimizer</a></li>
</ul>
<h3 id="1-0-3">1.0.3</h3>
<p>Small bug fixes to:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?sort=created&direction=desc&state=closed&page=1&milestone=6">require.js</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=4">r.js optimizer</a></li>
</ul>
<h3 id="1-0-2">1.0.2</h3>
<p>Small bug fixes to:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?sort=created&direction=desc&state=closed&page=1&milestone=5">require.js</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?sort=created&direction=desc&state=closed&page=1&milestone=3">r.js optimizer</a></li>
</ul>
<h3 id="1-0-1">1.0.1</h3>
<p>Just small bug fixes related to:</p>
<ul>
<li>allowing full URLs for simplified CommonJS wrapped modules</li>
<li>AST parsing of dependencies for modules that use a variable for the factory function</li>
<li>catching more cases that should have the "namespace" optimizer option applied</li>
</ul>
<p>Detailed list of changes for require.js and the r.js optimizer:</p>
<ul>
<li><a href="https://github.com/requirejs/requirejs/issues?milestone=4&state=closed">require.js 1.0.1 changes</a></li>
<li><a href="https://github.com/requirejs/r.js/issues?milestone=2&state=closed">r.js 1.0.1 changes</a></li>
</ul>
</div>
================================================
FILE: docs/errors.html
================================================
<div id="directory" class="section">
<h1>Common Errors</h1>
<ul class="index mono">
<li class="hbox"><a href="#mismatch">Mismatched anonymous define() modules ...</a><span class="spacer boxFlex"></span><span class="sect">§ 1</span></li>
<li class="hbox"><a href="#timeout">Load timeout for modules: ...</a><span class="spacer boxFlex"></span><span class="sect">§ 2</span></li>
<li class="hbox"><a href="#defineerror">Error evaluating module ...</a><span class="spacer boxFlex"></span><span class="sect">§ 3</span></li>
<li class="hbox"><a href="#notloaded">Module name ... has not been loaded yet for context: ...</a><span class="spacer boxFlex"></span><span class="sect">§ 4</span></li>
<li class="hbox"><a href="#requireargs">Invalid require call</a><span class="spacer boxFlex"></span><span class="sect">§ 5</span></li>
<li class="hbox"><a href="#nodefine">No define call for ...</a><span class="spacer boxFlex"></span><span class="sect">§ 6</span></li>
<li class="hbox"><a href="#scripterror">Script error</a><span class="spacer boxFlex"></span><span class="sect">§ 7</span></li>
<li class="hbox"><a href="#interactive">No matching script interactive for ...</a><span class="spacer boxFlex"></span><span class="sect">§ 8</span></li>
<li class="hbox"><a href="#pathnotsupported">Path is not supported: ...</a><span class="spacer boxFlex"></span><span class="sect">§ 9</span></li>
<li class="hbox"><a href="#sourcemapcomments">Cannot use preserveLicenseComments and generateSourceMaps together</a><span class="spacer boxFlex"></span><span class="sect">§ 10</span></li>
<li class="hbox"><a href="#importscripts">importScripts failed for ...</a><span class="spacer boxFlex"></span><span class="sect">§ 11</span></li>
</ul>
<p>This page lists errors that are generated by RequireJS. If the following information does not fix the problem, you can ask on the <a href="https://groups.google.com/group/requirejs">RequireJS list</a> or <a href="https://github.com/requirejs/requirejs/issues">open an issue</a>. In either case it is best to have an example or detailed explanation of the problem, hopefully with steps to reproduce.</p>
</div>
<div class="section">
<h2><a name="mismatch">Mismatched anonymous define() modules ...</a><span class="sectionMark">§ 1</span></h2>
<p>If you manually code a script tag in HTML to load a script with an anonymous define() call, this error can occur.</p>
<p>If you manually code a script tag in HTML to load a script that has a few named modules, but then try to load an anonymous module that ends up having the same name as one of the named modules in the script loaded by the manually coded script tag.</p>
<p>If you use the loader plugins or anonymous modules (modules that call define() with no string ID) but do not use the RequireJS optimizer to combine files together, this error can occur. The optimizer knows how to name anonymous modules correctly so that they can be combined with other modules in an optimized file.</p>
<p>If you use <code>var define;</code> at the top of your file for jshint/jslint purposes, this will cause a problem for the optimizer because it avoids parsing files that declare a <code>define</code> variable, since that may indicate a script that was created by a concatenation of some scripts that use a local define.</p>
<p>To avoid the error:</p>
<ul>
<li>Be sure to load all scripts that call define() via the RequireJS API. Do not manually code script tags in HTML to load scripts that have define() calls in them.</li>
<li>If you manually code an HTML script tag, be sure it only includes named modules, and that an anonymous module that will have the same name as one of the modules in that file is not loaded.</li>
<li>If the problem is the use of loader plugins or anonymous modules but the RequireJS optimizer is not used for file bundling, use the RequireJS optimizer.</li>
<li>If the problem is the <code>var define</code> lint approach, use <code>/*global define */</code> (no space before "global") comment style instead.</li>
</ul>
</div>
<div class="section">
<h2><a name="timeout">Load timeout for modules: ...</a><span class="sectionMark">§ 2</span></h2>
<p>Likely causes and fixes:</p>
<ul>
<li>There was a script error in one of the listed modules. If there is no script error in the browser's error console, and if you are using Firebug, try loading the page in another browser like Chrome or Safari. Sometimes script errors do not show up in Firebug.</li>
<li>The path configuration for a module is incorrect. Check the "Net" or "Network" tab in the browser's developer tools to see if there was a 404 for an URL that would map to the module name. Make sure the script file is in the right place. In some cases you may need to use the <a href="api.html#config">paths configuration</a> to fix the URL resolution for the script.</li>
<li>The paths config was used to set two module IDs to the same file, and that file only has one anonymous module in it. If module IDs "something" and "lib/something" are both configured to point to the same "scripts/libs/something.js" file, and something.js only has
one anonymous module in it, this kind of timeout error can occur. The fix is to make sure all module ID references use the same ID (either choose "something" or "lib/something" for all references), or use <a href="api.html#config-map">map config</a>.</li>
</ul>
</div>
<div class="section">
<h2><a name="defineerror">Error evaluating module ...</a><span class="sectionMark">§ 3</span></h2>
<p>An error occured when the define() function was called for the module given in the error message. It is an error with the code logic inside the define function. The error could happen inside a require callback.</p>
<p>In Firefox and WebKit browsers, a line number and file name will be indicated in the error. It can be used to locate
the source of the problem. Better isolation of the error can be done by using a debugger to place a
breakpoint in the file that contains the error.</p>
</div>
<div class="section">
<h2><a name="notloaded">Module name ... has not been loaded yet for context: ...</a><span class="sectionMark">§ 4</span></h2>
<p>This occurs when there is a require('name') call, but the 'name' module has not been loaded yet.</p>
<p>If the error message includes <strong>Use require([])</strong>, then
it was a top-level require call (not a require call inside a define() call) that should be using the async, callback version of require to load the code:</p>
<pre><code>//If this code is not in a define call,
//DO NOT use require('foo'), but use the async
//callback version:
require(['foo'], function (foo) {
//foo is now loaded.
});
</code></pre>
<p>If you are using the simplified define wrapper, make sure you have <strong>require</strong> as the first argument to the definition function:</p>
<pre><code>define(function (require) {
var namedModule = require('name');
});
</code></pre>
<p>If you are listing dependencies in the dependency array, make sure that <strong>require</strong> and <strong>name</strong> are in the dependency array:</p>
<pre><code>define(['require', 'name'], function (require) {
var namedModule = require('name');
});
</code></pre>
<p>In particular, <strong>the following will not work</strong>:</p>
<pre><code>//THIS WILL FAIL
define(['require'], function (require) {
var namedModule = require('name');
});
</code></pre>
<p>This fails because requirejs needs to be sure to load and execute all dependencies
before calling the factory function above. If a dependency array is given to define(),
then requirejs assumes that all dependencies are listed in that array, and it will
not scan the factory function for other dependencies. So, either do not pass in the dependency array, or if using the dependency array, list all the dependencies in it.</p>
<p>If part of a require() callback, all the dependencies need to be listed in the array:</p>
<pre><code>require(['require', 'name'], function (require) {
var namedModule = require('name');
});
</code></pre>
<p>Be sure that <strong>require('name')</strong> only occurs inside a define() definition function or a require() callback function, never in the global space by its own.</p>
<p><strong>In the RequreJS 1.0.x releases</strong>, there <a href="https://github.com/requirejs/requirejs/issues/265">is a bug</a> with having a space between the require and parens in WebKit browsers when using the simplified CommonJS wrapping (no dependency array):</p>
<pre><code>define(function (require) {
//Notice the space between require and the arguments.
var namedModule = require ('name');
});
</code></pre>
<p>The workaround is to just remove the space. This is fixed in the 2.0 code, and may be backported to the 1.0.x series if a 1.0.9 release is done.</p>
</div>
<div class="section">
<h2><a name="requireargs">Invalid require call</a><span class="sectionMark">§ 5</span></h2>
<p>This occurs when there is a call like:</p>
<pre><code>require('dependency', function (dependency) {});
</code></pre>
<p>Asynchronously loading dependencies should use an array to list the dependencies:</p>
<pre><code>require(['dependency'], function (dependency) {});
</code></pre>
</div>
<div class="section">
<h2><a name="nodefine">No define call for ...</a><span class="sectionMark">§ 6</span></h2>
<p>This occurs when <a href="api.html##config-enforceDefine">enforceDefine is set to true</a>, and a script that is loaded either:</p>
<ul>
<li>Did not call define() to declare a module.</li>
gitextract_p4byhwra/ ├── .github/ │ └── CONTRIBUTING.md ├── .gitignore ├── .jscsrc ├── .jshintrc ├── .travis.yml ├── LICENSE ├── README.md ├── dist/ │ ├── Markdown-License.text │ ├── Markdown.pl │ ├── README.md │ ├── dist-build.sh │ ├── dist-site.js │ ├── file.js │ ├── fonts/ │ │ └── PT-Sans/ │ │ └── Paratype PT Sans Free Font License.txt │ ├── init.js │ ├── post.html │ └── pre.html ├── docs/ │ ├── api.html │ ├── commonjs.html │ ├── contributing.html │ ├── design/ │ │ └── packages.md │ ├── dojo.html │ ├── download.html │ ├── errors.html │ ├── faq-advanced.html │ ├── faq-optimization.html │ ├── faq.html │ ├── history.html │ ├── jquery.html │ ├── node.html │ ├── optimization.html │ ├── plugins.html │ ├── requirements.html │ ├── start.html │ ├── why.html │ └── whyamd.html ├── index.html ├── package.json ├── require.js ├── tasks.txt ├── testBaseUrl.js ├── tests/ │ ├── NAMESPACE.html │ ├── afterload.html │ ├── afterloadreadystate.js │ ├── all.js │ ├── anon/ │ │ ├── a.js │ │ ├── anon-tests.js │ │ ├── anonSimple.html │ │ ├── blue.js │ │ ├── c.js │ │ ├── green.js │ │ ├── magenta.js │ │ ├── message.txt │ │ ├── red.js │ │ ├── sub/ │ │ │ └── b.js │ │ └── yellow.js │ ├── bar │ ├── baseUrl.html │ ├── bundles/ │ │ ├── bundles-tests.js │ │ ├── bundles.html │ │ ├── main.js │ │ ├── second.js │ │ └── third.js │ ├── circular/ │ │ ├── 414/ │ │ │ ├── 414-tests.js │ │ │ ├── 414.html │ │ │ ├── A.js │ │ │ ├── B.js │ │ │ ├── C.js │ │ │ └── MyClass.js │ │ ├── a.js │ │ ├── b.js │ │ ├── c.js │ │ ├── circularPlugin-tests.js │ │ ├── circularPlugin.html │ │ ├── complexPlugin/ │ │ │ ├── complexPlugin-tests.js │ │ │ ├── complexPlugin.html │ │ │ ├── helper.js │ │ │ ├── main.js │ │ │ ├── slowText.js │ │ │ ├── toolbar.html │ │ │ ├── toolbar.js │ │ │ ├── viewport.html │ │ │ └── viewport.js │ │ ├── dupe/ │ │ │ ├── dupe.html │ │ │ ├── exported.js │ │ │ └── func.js │ │ ├── plugin.js │ │ └── transpiler/ │ │ ├── a.refine │ │ ├── b.refine │ │ ├── c.refine │ │ ├── d.refine │ │ ├── e.refine │ │ ├── transpiler-tests.js │ │ └── transpiler.html │ ├── circular-tests.js │ ├── circular.html │ ├── cjsSpace/ │ │ ├── a.js │ │ ├── b.js │ │ ├── c.js │ │ ├── cjsDotRequire-tests.js │ │ ├── cjsDotRequire.html │ │ ├── cjsSpace-tests.js │ │ └── cjsSpace.html │ ├── commentParen/ │ │ ├── a.js │ │ ├── b.js │ │ └── commentParen.html │ ├── commonjs/ │ │ └── tests/ │ │ └── modules/ │ │ └── 1.0/ │ │ ├── absolute/ │ │ │ ├── b.js │ │ │ ├── program.html │ │ │ ├── program.js │ │ │ ├── submodule/ │ │ │ │ └── a.js │ │ │ └── test.js │ │ ├── all.html │ │ ├── cyclic/ │ │ │ ├── a.js │ │ │ ├── b.js │ │ │ ├── program.html │ │ │ ├── program.js │ │ │ └── test.js │ │ ├── determinism/ │ │ │ ├── program.html │ │ │ ├── program.js │ │ │ ├── submodule/ │ │ │ │ ├── a.js │ │ │ │ └── b.js │ │ │ └── test.js │ │ ├── exactExports/ │ │ │ ├── a.js │ │ │ ├── program.html │ │ │ ├── program.js │ │ │ └── test.js │ │ ├── hasOwnProperty/ │ │ │ ├── hasOwnProperty.js │ │ │ ├── program.html │ │ │ ├── program.js │ │ │ ├── test.js │ │ │ └── toString.js │ │ ├── method/ │ │ │ ├── a.js │ │ │ ├── program.html │ │ │ ├── program.js │ │ │ └── test.js │ │ ├── missing/ │ │ │ ├── program.html │ │ │ ├── program.js │ │ │ └── test.js │ │ ├── monkeys/ │ │ │ ├── a.js │ │ │ ├── program.html │ │ │ ├── program.js │ │ │ └── test.js │ │ ├── nested/ │ │ │ ├── a/ │ │ │ │ └── b/ │ │ │ │ └── c/ │ │ │ │ └── d.js │ │ │ ├── program.html │ │ │ ├── program.js │ │ │ └── test.js │ │ ├── relative/ │ │ │ ├── program.html │ │ │ ├── program.js │ │ │ ├── submodule/ │ │ │ │ ├── a.js │ │ │ │ └── b.js │ │ │ └── test.js │ │ ├── system.js │ │ ├── test.js │ │ └── transitive/ │ │ ├── a.js │ │ ├── b.js │ │ ├── c.js │ │ ├── program.html │ │ ├── program.js │ │ └── test.js │ ├── config.html │ ├── configRequirejs.html │ ├── dataMain/ │ │ ├── baseUrl/ │ │ │ ├── a.js │ │ │ ├── dataMainBaseUrl.html │ │ │ └── src/ │ │ │ └── main.js │ │ ├── dataMain.html │ │ ├── dataMain.js │ │ ├── dataMainIndex/ │ │ │ ├── dataMainIndex.html │ │ │ └── index.js │ │ ├── dataMainPlugin/ │ │ │ ├── dataMainPlugin.html │ │ │ ├── modules/ │ │ │ │ └── sub/ │ │ │ │ ├── a.js │ │ │ │ └── test.js │ │ │ └── my/ │ │ │ └── plugin.js │ │ └── skipDataMain/ │ │ ├── a.js │ │ ├── index.js │ │ └── skipDataMain.html │ ├── datauri/ │ │ └── datauri.html │ ├── defineDouble/ │ │ └── defineDouble.html │ ├── definedSpecified/ │ │ ├── a.js │ │ ├── b.js │ │ ├── definedSpecified-tests.js │ │ └── definedSpecified.html │ ├── delayedDefine/ │ │ ├── delayedDefine-tests.js │ │ └── delayedDefine.html │ ├── depEmpty.html │ ├── depoverlap.html │ ├── depoverlap.js │ ├── dimple.js │ ├── doh/ │ │ ├── LICENSE │ │ ├── README │ │ ├── _browserRunner.js │ │ ├── _nodeRunner.js │ │ ├── _rhinoRunner.js │ │ ├── _sounds/ │ │ │ └── LICENSE │ │ ├── runner.html │ │ ├── runner.js │ │ └── runner.sh │ ├── domReady/ │ │ ├── domReady-tests.js │ │ ├── domReady.html │ │ ├── domReadyExtraConfig-tests.js │ │ ├── domReadyExtraConfig.html │ │ ├── one.js │ │ └── two.js │ ├── dos.js │ ├── dotTrim/ │ │ ├── b.js │ │ ├── dotTrim-tests.js │ │ ├── dotTrim.html │ │ ├── spell.js │ │ ├── sub/ │ │ │ └── ext.js │ │ └── util/ │ │ └── helper.js │ ├── error/ │ │ ├── a.js │ │ ├── b.js │ │ ├── c.js │ │ ├── d.js │ │ ├── defineError.js │ │ ├── defineErrorLocal.html │ │ ├── doubleRequire/ │ │ │ ├── b.js │ │ │ ├── c.js │ │ │ └── doubleRequire.html │ │ ├── errorChild.html │ │ ├── errorContinue.html │ │ ├── errorContinueLocal.html │ │ ├── globalOnError.html │ │ ├── plug.js │ │ ├── pluginErrorContinue.html │ │ ├── pluginErrorContinueLocal.html │ │ └── requireErrback.html │ ├── exports/ │ │ ├── am.js │ │ ├── assign.js │ │ ├── assign2.js │ │ ├── bm.js │ │ ├── cm.js │ │ ├── exports-tests.js │ │ ├── exports.html │ │ ├── funcSet.js │ │ ├── implicitModule.js │ │ ├── moduleAndExports-tests.js │ │ ├── moduleAndExports.html │ │ ├── simpleReturn.js │ │ ├── usethis.js │ │ └── vanilla.js │ ├── foo │ ├── func.js │ ├── funcFour.js │ ├── funcOne.js │ ├── funcThree.js │ ├── funcTwo.js │ ├── hasOwnProperty/ │ │ ├── hasOwnProperty-tests.js │ │ ├── hasOwnProperty.html │ │ ├── hasOwnProperty.js │ │ ├── prototype.js │ │ └── toString.js │ ├── i18n/ │ │ ├── common.html │ │ ├── commonA.js │ │ ├── commonB.js │ │ ├── i18n.html │ │ ├── nls/ │ │ │ ├── colors.js │ │ │ ├── en-us-surfer/ │ │ │ │ └── colors.js │ │ │ └── fr/ │ │ │ └── colors.js │ │ └── testModule.js │ ├── index.html │ ├── isBrowser/ │ │ ├── a.js │ │ ├── isBrowser-tests.js │ │ └── isBrowser.html │ ├── issue379/ │ │ ├── issue379.html │ │ └── issue379.js │ ├── jquery/ │ │ ├── jquery.html │ │ ├── jqueryDynamic.html │ │ ├── jqueryDynamic2.html │ │ └── scripts/ │ │ ├── app.js │ │ ├── dynamicApp.js │ │ ├── jquery-1.7.1.js │ │ ├── jquery-GPL-LICENSE.txt │ │ ├── jquery-MIT-LICENSE.txt │ │ ├── jquery.alpha.js │ │ ├── jquery.beta.js │ │ ├── jquery.epsilon.js │ │ └── jquery.gamma.js │ ├── jsonp/ │ │ ├── jsonp.html │ │ ├── lamp.js │ │ └── twitter.html │ ├── layers/ │ │ ├── build.sh │ │ ├── epsilon.js │ │ ├── helloWorld.txt │ │ ├── layer1.js │ │ └── layers.html │ ├── map.js │ ├── mapConfig/ │ │ ├── a1/ │ │ │ └── sub/ │ │ │ └── one.js │ │ ├── a1.js │ │ ├── adapter/ │ │ │ └── d.js │ │ ├── another/ │ │ │ ├── c/ │ │ │ │ ├── dim.js │ │ │ │ └── sub.js │ │ │ ├── c.js │ │ │ └── minor.js │ │ ├── b.js │ │ ├── built/ │ │ │ ├── mapConfig-tests.js │ │ │ ├── mapConfigBuilt.html │ │ │ ├── mapConfigPlugin-tests.js │ │ │ ├── mapConfigPluginBuilt.html │ │ │ ├── mapConfigStar-tests.js │ │ │ ├── mapConfigStarAdapter-tests.js │ │ │ ├── mapConfigStarAdapterBuilt.html │ │ │ └── mapConfigStarBuilt.html │ │ ├── c/ │ │ │ └── sub.js │ │ ├── c.js │ │ ├── c1/ │ │ │ └── sub.js │ │ ├── c1.js │ │ ├── c2/ │ │ │ └── sub.js │ │ ├── c2.js │ │ ├── d.js │ │ ├── e.js │ │ ├── mapConfig-tests.js │ │ ├── mapConfig.html │ │ ├── mapConfigDelayed-tests.js │ │ ├── mapConfigDelayed.html │ │ ├── mapConfigMulti-tests.js │ │ ├── mapConfigMulti.html │ │ ├── mapConfigPlugin-tests.js │ │ ├── mapConfigPlugin.html │ │ ├── mapConfigRelative-tests.js │ │ ├── mapConfigRelative.html │ │ ├── mapConfigSpecificity-tests.js │ │ ├── mapConfigSpecificity.html │ │ ├── mapConfigStar-tests.js │ │ ├── mapConfigStar.html │ │ ├── mapConfigStarAdapter-tests.js │ │ ├── mapConfigStarAdapter.html │ │ ├── plug/ │ │ │ ├── c1.js │ │ │ ├── c2.js │ │ │ └── main.js │ │ └── plug.js │ ├── moduleConfig/ │ │ ├── a.js │ │ ├── b/ │ │ │ └── c.js │ │ ├── moduleConfig-tests.js │ │ ├── moduleConfig.html │ │ └── plain.js │ ├── moduleExports/ │ │ ├── adder.js │ │ └── moduleExports.html │ ├── multiversion.html │ ├── nestedDefine/ │ │ ├── four.js │ │ ├── nestedDefine.html │ │ ├── nestedDefine2.html │ │ ├── nestedDefine2.js │ │ ├── one.js │ │ └── two.js │ ├── nestedRelativeRequire/ │ │ ├── main.js │ │ ├── nestedRelativeRequire.html │ │ └── sub/ │ │ ├── a.js │ │ └── b.js │ ├── nestedRequire/ │ │ ├── a.js │ │ ├── base.js │ │ ├── nestedRequire-tests.js │ │ └── nestedRequire.html │ ├── nestedRequireConfig/ │ │ ├── nestedRequireConfig.html │ │ └── nestedRequireConfig.js │ ├── onResourceLoad/ │ │ ├── a.js │ │ ├── b.js │ │ ├── nestedRequire-tests.js │ │ └── nestedRequire.html │ ├── one.js │ ├── packages/ │ │ ├── bar/ │ │ │ └── 0.4/ │ │ │ └── scripts/ │ │ │ └── main.js │ │ ├── baz/ │ │ │ └── lib/ │ │ │ ├── helper.js │ │ │ └── index.js │ │ ├── config/ │ │ │ ├── config.html │ │ │ └── pixie/ │ │ │ └── index.js │ │ ├── dojox/ │ │ │ ├── door.js │ │ │ └── window/ │ │ │ ├── pane.js │ │ │ └── window.js │ │ ├── foo/ │ │ │ └── lib/ │ │ │ ├── main.js │ │ │ └── second.js │ │ ├── funky/ │ │ │ ├── index.js │ │ │ └── lib/ │ │ │ └── monkey.js │ │ ├── optimizing/ │ │ │ ├── build.js │ │ │ ├── main.js │ │ │ ├── optimizing-built.html │ │ │ ├── optimizing.html │ │ │ └── packages/ │ │ │ ├── engine/ │ │ │ │ ├── main.js │ │ │ │ ├── pistons.js │ │ │ │ └── sparkplugs.js │ │ │ ├── fuel/ │ │ │ │ └── main.js │ │ │ └── tires/ │ │ │ └── main.js │ │ ├── packages-tests.js │ │ ├── packages.html │ │ ├── pkgs/ │ │ │ ├── alpha/ │ │ │ │ ├── main.js │ │ │ │ └── replace.js │ │ │ ├── beta/ │ │ │ │ └── 0.2/ │ │ │ │ └── scripts/ │ │ │ │ ├── beta.js │ │ │ │ └── util.js │ │ │ └── dojox/ │ │ │ ├── chair/ │ │ │ │ ├── legs.js │ │ │ │ └── main.js │ │ │ └── table/ │ │ │ ├── legs.js │ │ │ └── table.js │ │ └── replace.js │ ├── packagesMultiLevel/ │ │ ├── @foo/ │ │ │ └── bar@1.0.0/ │ │ │ ├── index.js │ │ │ └── other.js │ │ ├── baz@2.0.0/ │ │ │ ├── helper.js │ │ │ └── index.js │ │ ├── build.js │ │ ├── config.js │ │ ├── expected-built.js │ │ ├── packagesMultiLevel-built.html │ │ ├── packagesMultiLevel-tests-built.js │ │ ├── packagesMultiLevel-tests.js │ │ └── packagesMultiLevel.html │ ├── packagesNestedMain/ │ │ ├── foo/ │ │ │ └── lib/ │ │ │ ├── bar.js │ │ │ └── index.js │ │ ├── packagesNestedMain-tests.js │ │ └── packagesNestedMain.html │ ├── packagesNode/ │ │ ├── packagesNode-tests.js │ │ └── packagesNode.html │ ├── packagesNodeAdapter/ │ │ ├── packagesNodeAdapter-tests.js │ │ └── packagesNodeAdapter.html │ ├── pathArray/ │ │ ├── pathArray.html │ │ ├── pathArrayFail.html │ │ ├── real.js │ │ └── withMap/ │ │ ├── dep-private.js │ │ ├── real.js │ │ └── withMap.html │ ├── paths/ │ │ ├── first.js/ │ │ │ ├── first.js │ │ │ └── second.js │ │ ├── impl/ │ │ │ ├── array.js │ │ │ └── util.js │ │ ├── paths.html │ │ ├── relativeModuleId-tests.js │ │ ├── relativeModuleId.html │ │ ├── relativeNormalize/ │ │ │ ├── bar/ │ │ │ │ └── baz.js │ │ │ ├── foo2.js │ │ │ ├── relativeNormalize-tests.js │ │ │ └── relativeNormalize.html │ │ └── util.js │ ├── pluginNormalize/ │ │ └── pluginNormalize.html │ ├── pluginNormalizeLoad/ │ │ ├── Plugin.js │ │ └── pluginNormalizeLoad.html │ ├── plugins/ │ │ ├── a.js │ │ ├── b.js │ │ ├── c.js │ │ ├── complexNormalize/ │ │ │ ├── complexNormalize.html │ │ │ ├── main.js │ │ │ └── sub/ │ │ │ ├── modA1.js │ │ │ ├── modA2.js │ │ │ ├── plugin.js │ │ │ └── pluginDep.js │ │ ├── delegated/ │ │ │ ├── a.refine │ │ │ ├── delegated-tests.js │ │ │ ├── delegated.html │ │ │ └── delegated.js │ │ ├── double.html │ │ ├── double.js │ │ ├── earth.js │ │ ├── fromText/ │ │ │ ├── a.refine │ │ │ ├── b.refine │ │ │ ├── fromText-tests.js │ │ │ ├── fromText.html │ │ │ ├── fromTextConfig-tests.js │ │ │ ├── fromTextConfig.html │ │ │ └── refine.js │ │ ├── fromTextEvalError/ │ │ │ ├── a.refine │ │ │ ├── b.refine │ │ │ ├── fromTextEvalError-tests.js │ │ │ └── fromTextEvalError.html │ │ ├── fromTextNoDefine/ │ │ │ ├── a.refine │ │ │ ├── fromTextNoDefine-tests.js │ │ │ ├── fromTextNoDefine.html │ │ │ └── refine.js │ │ ├── index.js │ │ ├── indexBuilder.js │ │ ├── nameOnly-tests.js │ │ ├── nameOnly.html │ │ ├── nameOnly.js │ │ ├── onerror/ │ │ │ ├── onerror-tests.js │ │ │ ├── onerror.html │ │ │ └── thrower.js │ │ ├── pluginBundles/ │ │ │ ├── main.js │ │ │ ├── pluginBundles-tests.js │ │ │ └── pluginBundles.html │ │ ├── pluginBundlesSeparateText/ │ │ │ ├── main.js │ │ │ ├── pluginBundlesSeparateText-tests.js │ │ │ ├── pluginBundlesSeparateText.html │ │ │ └── second.html │ │ ├── pluginLast/ │ │ │ ├── app.js │ │ │ ├── bigCollection.html │ │ │ ├── bigCollection.js │ │ │ ├── collection.js │ │ │ ├── collectionHelper.js │ │ │ ├── common.js │ │ │ ├── component.html │ │ │ ├── component.js │ │ │ ├── main.js │ │ │ ├── pluginLast.html │ │ │ ├── specificCollection.html │ │ │ └── specificCollection.js │ │ ├── pluginMap/ │ │ │ ├── dynamic/ │ │ │ │ ├── application.js │ │ │ │ ├── employee.js │ │ │ │ ├── main.js │ │ │ │ ├── person.js │ │ │ │ ├── plugin.js │ │ │ │ └── pluginMapDynamic.html │ │ │ ├── pluginMap-tests.js │ │ │ └── pluginMap.html │ │ ├── pluginMapSameName/ │ │ │ ├── plugin/ │ │ │ │ └── plugin.js │ │ │ ├── pluginMapSameName-tests.js │ │ │ └── pluginMapSameName.html │ │ ├── pluginNormalize/ │ │ │ ├── modA.js │ │ │ ├── modB.js │ │ │ ├── pluginNormalize-tests.js │ │ │ └── pluginNormalize.html │ │ ├── pluginShim/ │ │ │ ├── a.refine │ │ │ ├── legacy.js │ │ │ ├── pluginShim-tests.js │ │ │ └── pluginShim.html │ │ ├── prime/ │ │ │ ├── a.js │ │ │ ├── b.js │ │ │ ├── c.js │ │ │ └── earth.js │ │ ├── sync-tests.js │ │ ├── sync.html │ │ └── textDepend/ │ │ ├── test.txt │ │ ├── textDepend-tests.js │ │ ├── textDepend.html │ │ └── textDepend.js │ ├── queryPath.html │ ├── relative/ │ │ ├── foo/ │ │ │ ├── bar/ │ │ │ │ ├── message.txt │ │ │ │ ├── one.js │ │ │ │ └── two.js │ │ │ ├── bar.js │ │ │ └── three.js │ │ ├── greek/ │ │ │ ├── alpha.js │ │ │ └── main.js │ │ ├── outsideBaseUrl/ │ │ │ ├── 2.js │ │ │ ├── a/ │ │ │ │ └── outsideBaseUrl.html │ │ │ └── b/ │ │ │ ├── 1.js │ │ │ └── 3.js │ │ ├── relative-tests.js │ │ ├── relative.html │ │ ├── relativeBaseUrl-tests.js │ │ ├── relativeBaseUrl.html │ │ └── top.js │ ├── remoteUrls/ │ │ ├── jqwrap.js │ │ ├── remoteUrls-tests.js │ │ ├── remoteUrls.html │ │ ├── util.js │ │ └── util2.js │ ├── requireAsync/ │ │ ├── requireAsync-tests.js │ │ └── requireAsync.html │ ├── requirePluginLoad/ │ │ ├── requirePluginLoad-tests.js │ │ └── requirePluginLoad.html │ ├── secondLateConfigPlugin/ │ │ ├── app/ │ │ │ └── lib_/ │ │ │ ├── amd/ │ │ │ │ ├── nonamd.js │ │ │ │ └── text.js │ │ │ ├── jquery.foo.js │ │ │ └── jquery.js │ │ ├── plugin1_ko/ │ │ │ ├── A.js │ │ │ └── jquery.bar.js │ │ └── secondLateConfigPlugin.html │ ├── setTimeout-tests.js │ ├── setTimeout.html │ ├── shim/ │ │ ├── a.js │ │ ├── b.js │ │ ├── basic-tests.js │ │ ├── basic.html │ │ ├── built/ │ │ │ ├── basic-built.html │ │ │ └── basic-tests.js │ │ ├── c.js │ │ ├── d.js │ │ ├── e.js │ │ └── f.js │ ├── simple-badbase.html │ ├── simple-nohead.html │ ├── simple-tests.js │ ├── simple.html │ ├── simple.js │ ├── specialDeps/ │ │ ├── foo.js │ │ ├── specialDeps-tests.js │ │ └── specialDeps.html │ ├── text/ │ │ ├── local.js │ │ ├── plain.txt │ │ ├── resources/ │ │ │ ├── local.html │ │ │ └── sample.html │ │ ├── separate.js │ │ ├── subwidget.html │ │ ├── subwidget.js │ │ ├── subwidget2.html │ │ ├── text.html │ │ ├── textBuilt.html │ │ ├── textBuilt.js │ │ ├── textOnError.html │ │ ├── textOnXhr.html │ │ ├── textOnly.html │ │ ├── widget.html │ │ └── widget.js │ ├── toUrl/ │ │ ├── .hidden.html │ │ ├── auxil.html │ │ ├── main.html │ │ ├── main.js │ │ ├── sub/ │ │ │ ├── nested/ │ │ │ │ └── thing.js │ │ │ ├── noext │ │ │ ├── util.html │ │ │ └── util.js │ │ ├── toUrl-tests.js │ │ └── toUrl.html │ ├── trailingComma/ │ │ ├── a.js │ │ ├── trailingComma.html │ │ └── trailingComma.js │ ├── tres.js │ ├── two.js │ ├── undef/ │ │ ├── globalFoo.js │ │ ├── real.js │ │ ├── undef.html │ │ ├── undefEnforceShim.html │ │ ├── undefLocal.html │ │ ├── undefNoRequire.html │ │ └── undefNoRequire2.html │ ├── uniques/ │ │ ├── one.js │ │ ├── three.js │ │ ├── two.js │ │ └── uniques.html │ ├── universal/ │ │ ├── eye.js │ │ ├── newt.js │ │ ├── spell.js │ │ ├── tail.js │ │ ├── universal-built.html │ │ ├── universal-tests-built-expected.js │ │ ├── universal-tests-built.js │ │ ├── universal-tests.js │ │ └── universal.html │ ├── uno.js │ ├── unorderedDefine/ │ │ ├── app.js │ │ ├── bar.js │ │ └── unorderedDefine.html │ ├── urlArgsBlob.html │ ├── urlArgsToUrl.html │ ├── urlArgsToUrlFunction.html │ ├── urlfetch/ │ │ ├── one.js │ │ ├── three.js │ │ ├── two.js │ │ └── urlfetch.html │ ├── version1/ │ │ ├── alpha.js │ │ ├── beta.js │ │ ├── gamma.js │ │ └── omega.js │ ├── version2/ │ │ ├── alpha.js │ │ ├── beta.js │ │ ├── epsilon.js │ │ └── omega.js │ ├── workers.html │ └── workers.js └── updatesubs.sh
SYMBOL INDEX (77 symbols across 19 files)
FILE: dist/dist-site.js
function processFile (line 33) | function processFile() {
FILE: dist/file.js
function mkDir (line 8) | function mkDir(dir) {
function mkFullDir (line 14) | function mkFullDir(dir) {
FILE: require.js
function commentReplace (line 39) | function commentReplace(match, singlePrefix) {
function isFunction (line 43) | function isFunction(it) {
function isArray (line 47) | function isArray(it) {
function each (line 55) | function each(ary, func) {
function eachReverse (line 70) | function eachReverse(ary, func) {
function hasProp (line 81) | function hasProp(obj, prop) {
function getOwn (line 85) | function getOwn(obj, prop) {
function eachProp (line 94) | function eachProp(obj, func) {
function mixin (line 109) | function mixin(target, source, force, deepStringMixin) {
function bind (line 132) | function bind(obj, fn) {
function scripts (line 138) | function scripts() {
function defaultOnError (line 142) | function defaultOnError(err) {
function getGlobal (line 148) | function getGlobal(value) {
function makeError (line 167) | function makeError(id, msg, err, requireModules) {
function newContext (line 199) | function newContext(contextName) {
function getInteractiveScript (line 1993) | function getInteractiveScript() {
FILE: tests/circular/dupe/func.js
function func (line 2) | function func(title) {
FILE: tests/domReady/domReady-tests.js
function finished (line 13) | function finished() {
FILE: tests/domReady/domReadyExtraConfig-tests.js
function finished (line 15) | function finished() {
FILE: tests/jquery/scripts/jquery-1.7.1.js
function jQuerySub (line 871) | function jQuerySub( selector, context ) {
function doScrollCheck (line 937) | function doScrollCheck() {
function createFlags (line 964) | function createFlags( flags ) {
function resolveFunc (line 1296) | function resolveFunc( i ) {
function progressFunc (line 1304) | function progressFunc( i ) {
function dataAttr (line 1931) | function dataAttr( elem, key, data ) {
function isEmptyDataObject (line 1962) | function isEmptyDataObject( obj ) {
function handleQueueMarkDefer (line 1980) | function handleQueueMarkDefer( elem, type, src ) {
function resolve (line 2133) | function resolve() {
function returnFalse (line 3465) | function returnFalse() {
function returnTrue (line 3468) | function returnTrue() {
function dirNodeCheck (line 5168) | function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
function dirCheck (line 5201) | function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
function isDisconnected (line 5474) | function isDisconnected( node ) {
function winnow (line 5591) | function winnow( elements, qualifier, keep ) {
function createSafeFragment (line 5628) | function createSafeFragment( document ) {
function root (line 5992) | function root( elem, cur ) {
function cloneCopyEvent (line 5999) | function cloneCopyEvent( src, dest ) {
function cloneFixAttributes (line 6027) | function cloneFixAttributes( src, dest ) {
function getAll (line 6163) | function getAll( elem ) {
function fixDefaultChecked (line 6176) | function fixDefaultChecked( elem ) {
function findInputs (line 6182) | function findInputs( elem ) {
function shimCloneNode (line 6193) | function shimCloneNode( elem ) {
function evalScript (line 6425) | function evalScript( i, elem ) {
function getWH (line 6767) | function getWH( elem, name, extra ) {
function addToPrefiltersOrTransports (line 6895) | function addToPrefiltersOrTransports( structure ) {
function inspectPrefiltersOrTransports (line 6931) | function inspectPrefiltersOrTransports( structure, options, originalOpti...
function ajaxExtend (line 6973) | function ajaxExtend( target, src ) {
function done (line 7315) | function done( status, nativeStatusText, responses, headers ) {
function buildParams (line 7630) | function buildParams( prefix, obj, traditional, add ) {
function ajaxHandleResponses (line 7680) | function ajaxHandleResponses( s, jqXHR, responses ) {
function ajaxConvert (line 7745) | function ajaxConvert( s, response ) {
function createStandardXHR (line 8011) | function createStandardXHR() {
function createActiveXHR (line 8017) | function createActiveXHR() {
function doAnimation (line 8349) | function doAnimation() {
function stopQueue (line 8492) | function stopQueue( elem, data, index ) {
function createFxNow (line 8534) | function createFxNow() {
function clearFxNow (line 8539) | function clearFxNow() {
function genFx (line 8544) | function genFx( type, num ) {
function t (line 8659) | function t( gotoEnd ) {
function defaultDisplay (line 8851) | function defaultDisplay( nodeName ) {
function getWindow (line 9160) | function getWindow( elem ) {
FILE: tests/jquery/scripts/jquery.epsilon.js
function plugin (line 3) | function plugin($) {
FILE: tests/jquery/scripts/jquery.gamma.js
function plugin (line 3) | function plugin($) {
FILE: tests/onResourceLoad/nestedRequire-tests.js
function finish (line 4) | function finish(a) {
FILE: tests/plugins/fromText/refine.js
function createXhr (line 11) | function createXhr() {
FILE: tests/plugins/fromTextNoDefine/refine.js
function createXhr (line 11) | function createXhr() {
FILE: tests/plugins/index.js
function parse (line 3) | function parse(name) {
FILE: tests/plugins/indexBuilder.js
function parse (line 3) | function parse(name) {
FILE: tests/plugins/pluginLast/main.js
function trim (line 12) | function trim(text) {
FILE: tests/remoteUrls/jqwrap.js
function noop (line 21) | function noop() {}
FILE: tests/secondLateConfigPlugin/app/lib_/amd/nonamd.js
function compileNonAmd (line 139) | function compileNonAmd(jsText, moduleConfig, isBuild) {
function compileHeader (line 168) | function compileHeader(moduleConfig) {
FILE: tests/shim/built/basic-tests.js
function D (line 18) | function D() {
FILE: tests/shim/d.js
function D (line 1) | function D() {
Condensed preview — 644 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,220K chars).
[
{
"path": ".github/CONTRIBUTING.md",
"chars": 434,
"preview": "# Contributing to requirejs\n\n[See the requirejs.org contributing page](https://requirejs.org/docs/contributing.html).\n\nI"
},
{
"path": ".gitignore",
"chars": 212,
"preview": ".DS_Store\ndocs/jquery-require-sample/webapp-build/\ndocs/jquery-require-sample/dist\ndist/dist-site/\ndist/dist-build/\nshri"
},
{
"path": ".jscsrc",
"chars": 319,
"preview": "{\n \"preset\": \"google\",\n \"validateIndentation\": 4,\n \"disallowSpacesInAnonymousFunctionExpression\": null,\n \"disallowMu"
},
{
"path": ".jshintrc",
"chars": 53,
"preview": "{\n \"predef\": [\n \"console\"\n ],\n \"undef\": true\n}\n"
},
{
"path": ".travis.yml",
"chars": 48,
"preview": "sudo: false\nlanguage: node_js\nnode_js:\n - 0.12\n"
},
{
"path": "LICENSE",
"chars": 1904,
"preview": "Copyright jQuery Foundation and other contributors, https://jquery.org/\n\nThis software consists of voluntary contributio"
},
{
"path": "README.md",
"chars": 3268,
"preview": "# RequireJS\n\nRequireJS loads plain JavaScript files as well as more defined modules. It is\noptimized for in-browser use,"
},
{
"path": "dist/Markdown-License.text",
"chars": 1508,
"preview": "Copyright (c) 2004, John Gruber \n<http://daringfireball.net/> \nAll rights reserved.\n\nRedistribution and use in source "
},
{
"path": "dist/Markdown.pl",
"chars": 35622,
"preview": "#!/usr/bin/perl\n\n#\n# Markdown -- A text-to-HTML conversion tool for web writers\n#\n# Copyright (c) 2004 John Gruber\n# <ht"
},
{
"path": "dist/README.md",
"chars": 2247,
"preview": "# RequireJS dist\n\nThis directory contains the tools that are used to build distributions of RequireJS and its web site.\n"
},
{
"path": "dist/dist-build.sh",
"chars": 856,
"preview": "#!/bin/bash\n\n#version should be something like 0.9.0beta or 0.9.0\nversion=$1\nif [ -z $version ]; then\n echo \"Please p"
},
{
"path": "dist/dist-site.js",
"chars": 4160,
"preview": "/*\nTo run this file:\n\n> node dist-site.js\n\n*/\n\n/*jslint regexp: false, nomen: false, plusplus: false, strict: false */\n/"
},
{
"path": "dist/file.js",
"chars": 7187,
"preview": "/*jslint plusplus: false, octal:false, strict: false */\n/*global require: false, exports: false */\n\nvar fs = require('fs"
},
{
"path": "dist/fonts/PT-Sans/Paratype PT Sans Free Font License.txt",
"chars": 2502,
"preview": "Copyright © 2009 ParaType Ltd.\nwith Reserved Names \"PT Sans\" and \"ParaType\".\n\nFONT LICENSE\n\nPERMISSION & CONDITIONS\nPerm"
},
{
"path": "dist/init.js",
"chars": 1054,
"preview": "$(document).ready(function($) {\n\n // set panel min-height to full browser height\n $(window).bind(\"load resize\", fu"
},
{
"path": "dist/post.html",
"chars": 526,
"preview": " </div>\n <div id=\"footer\" class=\"mono\">\n <span class=\"line\">Latest Release: <a href=\"https://requirejs.org/"
},
{
"path": "dist/pre.html",
"chars": 7217,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>RequireJS</title>\n\n <meta name=\"viewport\" content=\"width=device-width, initi"
},
{
"path": "docs/api.html",
"chars": 77843,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>RequireJS API</h1>\n\n<ul class=\"index mono\">\n <li class=\"hbox\"><a href=\"#usag"
},
{
"path": "docs/commonjs.html",
"chars": 6053,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>CommonJS Notes</h1>\n\n<ul class=\"index mono\">\n<li class=\"hbox\"><a href=\"#intro\">"
},
{
"path": "docs/contributing.html",
"chars": 3306,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>Contributing to RequireJS</h1>\n\n<ul class=\"index mono\">\n<li class=\"hbox\"><a hre"
},
{
"path": "docs/design/packages.md",
"chars": 105,
"preview": "# Packages\n\nMoved to [pkg project](https://github.com/requirejs/pkg/blob/master/docs/design/packages.md)\n"
},
{
"path": "docs/dojo.html",
"chars": 518,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>How to use RequireJS with Dojo</h1>\n\n<p>As of Dojo 1.8, Dojo has converted thei"
},
{
"path": "docs/download.html",
"chars": 30436,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>Download RequireJS</h1>\n<ul class=\"index mono\">\n <li class=\"hbox\"><a href=\"#"
},
{
"path": "docs/errors.html",
"chars": 15035,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>Common Errors</h1>\n\n<ul class=\"index mono\">\n<li class=\"hbox\"><a href=\"#mismatch"
},
{
"path": "docs/faq-advanced.html",
"chars": 6167,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>FAQ: RequireJS Advanced Usage</h1>\n\n<ul class=\"index mono\">\n<li class=\"hbox\"><a"
},
{
"path": "docs/faq-optimization.html",
"chars": 3548,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>FAQ: RequireJS Optimizations</h1>\n<ul class=\"index mono\">\n<li class=\"hbox\"><a h"
},
{
"path": "docs/faq.html",
"chars": 406,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>RequireJS FAQs (Frequently Asked Questions)</h1>\n\n<ul class=\"index mono\">\n<li c"
},
{
"path": "docs/history.html",
"chars": 5722,
"preview": "<div id=\"directory\" class=\"section\">\n <h1>RequireJS History</h1>\n</div>\n\n<div class=\"section\">\n<p><a href=\"https://gi"
},
{
"path": "docs/jquery.html",
"chars": 8031,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>How to use RequireJS with jQuery</h1>\n\n<ul class=\"index mono\">\n <li class=\"h"
},
{
"path": "docs/node.html",
"chars": 10373,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>RequireJS in Node</h1>\n\n <ul class=\"index mono\">\n <li class=\"hbox\">\n "
},
{
"path": "docs/optimization.html",
"chars": 28802,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>RequireJS Optimizer</h1>\n\n<ul class=\"index mono\">\n<li class=\"hbox\"><a href=\"#re"
},
{
"path": "docs/plugins.html",
"chars": 20085,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>Plugins</h1>\n\n<ul class=\"index mono\">\n <li class=\"hbox\"><a href=\"#intro\">Int"
},
{
"path": "docs/requirements.html",
"chars": 7551,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>RequireJS Requirements</h1>\n\n<ul class=\"index mono\">\n <li class=\"hbox\">\n "
},
{
"path": "docs/start.html",
"chars": 4847,
"preview": "<div id=\"directory\" class=\"section\">\n <h1>How to get started with RequireJS</h1>\n\n <ul class=\"index mono\">\n "
},
{
"path": "docs/why.html",
"chars": 10738,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>Why Web Modules?</h1>\n\n<ul class=\"index mono\">\n <li class=\"hbox\">\n <a"
},
{
"path": "docs/whyamd.html",
"chars": 21210,
"preview": "<div id=\"directory\" class=\"section\">\n<h1>Why AMD?</h1>\n\n<ul class=\"index mono\">\n <li class=\"hbox\">\n <a href=\"#"
},
{
"path": "index.html",
"chars": 790,
"preview": "<div id=\"intro\" class=\"mono\">\n <p>/* ---</p>\n\n <p>RequireJS is a JavaScript file and module loader. It is optimize"
},
{
"path": "package.json",
"chars": 401,
"preview": "{\n \"name\": \"requirejs\",\n \"license\": \"MIT\",\n \"volo\": {\n \"url\": \"https://raw.github.com/requirejs/requirejs/{version"
},
{
"path": "require.js",
"chars": 86533,
"preview": "/** vim: et:ts=4:sw=4:sts=4\n * @license RequireJS 2.3.8 Copyright jQuery Foundation and other contributors.\n * Released "
},
{
"path": "tasks.txt",
"chars": 1276,
"preview": "Release Notes\n-------------------\n\nAfter merge/release:\n\n\nImplementation notes\n--------\n* Cannot get rid of interactive "
},
{
"path": "testBaseUrl.js",
"chars": 197,
"preview": "define([], function() {\n doh.register(\n 'testBaseUrl',\n [\n function testBaseUrl(t) {\n "
},
{
"path": "tests/NAMESPACE.html",
"chars": 1002,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: NAMESPACE Test</title>\n <script type=\"text/javascript\" src=\"NAME"
},
{
"path": "tests/afterload.html",
"chars": 3060,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: After Load</title>\n <script type=\"text/javascript\" src=\"doh/runn"
},
{
"path": "tests/afterloadreadystate.js",
"chars": 59,
"preview": "doh.is(\"complete\", document.readyState);\nd.callback(true);\n"
},
{
"path": "tests/all.js",
"chars": 11106,
"preview": "//PS3 does not have a usable Function.prototype.toString,\n//so avoid those tests.\nvar hasToString = (function () {\n v"
},
{
"path": "tests/anon/a.js",
"chars": 123,
"preview": "define(function (require) {\n var b = require(\"sub/b\");\n return {\n name: \"a\",\n bName: b.f()\n };\n}"
},
{
"path": "tests/anon/anon-tests.js",
"chars": 2091,
"preview": "require({\n baseUrl: requirejs.isBrowser ? \"./\" : \"anon/\",\n paths: {\n text: \"../../../text/text\""
},
{
"path": "tests/anon/anonSimple.html",
"chars": 490,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Simple Anonymous Module Test</title>\n <script type=\"text/javascr"
},
{
"path": "tests/anon/blue.js",
"chars": 65,
"preview": "define(function () {\n return {\n name: \"blue\"\n };\n});"
},
{
"path": "tests/anon/c.js",
"chars": 119,
"preview": "define(function (require) {\n var a = require('a');\n return {\n name: 'c',\n aName: a.name\n };\n});\n"
},
{
"path": "tests/anon/green.js",
"chars": 31,
"preview": "define({\n name: \"green\"\n});\n"
},
{
"path": "tests/anon/magenta.js",
"chars": 408,
"preview": "define(function (require, exports, module) {\n //This is a fakeout require(\"fake1\");\n\n var red = require(\"red\"),\n "
},
{
"path": "tests/anon/message.txt",
"chars": 11,
"preview": "hello world"
},
{
"path": "tests/anon/red.js",
"chars": 71,
"preview": "define(\"red\", function () {\n return {\n name: \"red\"\n };\n});"
},
{
"path": "tests/anon/sub/b.js",
"chars": 99,
"preview": "define(function(require, exports, module) { \n exports.f = function () { return \"sub/b\" }; \n});\n"
},
{
"path": "tests/anon/yellow.js",
"chars": 42,
"preview": "define(\"yellow\", {\n name: \"yellow\"\n});\n"
},
{
"path": "tests/bar",
"chars": 98,
"preview": "//A test for loading a file with a protocol-less URL via require()\n\nvar bar = {\n name: \"bar\"\n};"
},
{
"path": "tests/baseUrl.html",
"chars": 420,
"preview": "<!DOCTYPE html>\n<html>\n <head>\n <title>Default baseUrl Test</title>\n <script type=\"text/javascript\" src=\"do"
},
{
"path": "tests/bundles/bundles-tests.js",
"chars": 579,
"preview": "require({\n bundles: {\n 'main': ['util', 'main'],\n 'second': ['other'],\n 'third': ['third']\n }"
},
{
"path": "tests/bundles/bundles.html",
"chars": 600,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Bundles Config Test</title>\n <script type=\"text/javascript\" src="
},
{
"path": "tests/bundles/main.js",
"chars": 78,
"preview": "define('util', {\n name: 'util'\n});\n\ndefine('main', {\n name: 'main'\n});\n\n"
},
{
"path": "tests/bundles/second.js",
"chars": 40,
"preview": "define('other', {\n name: 'other'\n});\n"
},
{
"path": "tests/bundles/third.js",
"chars": 40,
"preview": "define('third', {\n name: 'third'\n});\n"
},
{
"path": "tests/circular/414/414-tests.js",
"chars": 411,
"preview": "require({\n baseUrl: requirejs.isBrowser ? './' : './circular/414'\n },\n [\"MyClass\"],\n function(MyClass) {"
},
{
"path": "tests/circular/414/414.html",
"chars": 740,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: #414: Multi-cycle Bundle Test</title>\n <script type=\"text/javasc"
},
{
"path": "tests/circular/414/A.js",
"chars": 292,
"preview": "define(\n [\n \"exports\",\n \"./MyClass\",\n \"./B\",\n \"./C\"\n ],\n\n function (exports, MyClas"
},
{
"path": "tests/circular/414/B.js",
"chars": 291,
"preview": "define(\n [\n \"exports\",\n \"./MyClass\",\n \"./A\",\n \"./C\"\n ],\n\n function (exports, MyClas"
},
{
"path": "tests/circular/414/C.js",
"chars": 293,
"preview": "define(\n [\n \"exports\",\n \"./MyClass\",\n \"./A\",\n \"./B\"\n ],\n\n function (exports, MyClas"
},
{
"path": "tests/circular/414/MyClass.js",
"chars": 505,
"preview": "define(\n [\n \"exports\",\n \"./A\",\n \"./B\",\n \"./C\"\n ],\n\n function (exports, A, B, C) {\n\n"
},
{
"path": "tests/circular/a.js",
"chars": 96,
"preview": "define(['b', 'exports'], function (b, exports) {\n exports.name = 'a';\n exports.b = b;\n});\n"
},
{
"path": "tests/circular/b.js",
"chars": 96,
"preview": "define(['c', 'exports'], function (c, exports) {\n exports.name = 'b';\n exports.c = c;\n});\n"
},
{
"path": "tests/circular/c.js",
"chars": 96,
"preview": "define(['a', 'exports'], function (a, exports) {\n exports.name = 'c';\n exports.a = a;\n});\n"
},
{
"path": "tests/circular/circularPlugin-tests.js",
"chars": 437,
"preview": "require({\n baseUrl: requirejs.isBrowser ? './' : './circular'\n },\n [\"require\", \"plugin!a\"],\n function(re"
},
{
"path": "tests/circular/circularPlugin.html",
"chars": 743,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Circular Dependency under Plugin Test</title>\n <script type=\"tex"
},
{
"path": "tests/circular/complexPlugin/complexPlugin-tests.js",
"chars": 711,
"preview": "require({\n baseUrl: requirejs.isBrowser ? './' : './circular/complexPlugin'\n },\n [\"require\", \"main\"],\n f"
},
{
"path": "tests/circular/complexPlugin/complexPlugin.html",
"chars": 661,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Complex Circular Dependency under Plugin Test</title>\n <script t"
},
{
"path": "tests/circular/complexPlugin/helper.js",
"chars": 141,
"preview": "define(function (require, exports) {\n //Create circular dependency here\n var main = require('main');\n\n exports."
},
{
"path": "tests/circular/complexPlugin/main.js",
"chars": 175,
"preview": "define(['exports', 'viewport', 'helper'], function (exports, viewport, helper) {\n\n exports.name = 'main';\n exports"
},
{
"path": "tests/circular/complexPlugin/slowText.js",
"chars": 12466,
"preview": "//Like text.js but does a setTimeout before returning a value, to simulate\n//slow template fetching.\n\n/**\n * @license Re"
},
{
"path": "tests/circular/complexPlugin/toolbar.html",
"chars": 15,
"preview": "toolbarTemplate"
},
{
"path": "tests/circular/complexPlugin/toolbar.js",
"chars": 127,
"preview": "define(function(require) {\n return {\n name: 'toolbar',\n template: require('slowText!toolbar.html')\n "
},
{
"path": "tests/circular/complexPlugin/viewport.html",
"chars": 16,
"preview": "viewportTemplate"
},
{
"path": "tests/circular/complexPlugin/viewport.js",
"chars": 166,
"preview": "define(function(require) {\n return {\n name: 'viewport',\n template: require('slowText!viewport.html'),\n "
},
{
"path": "tests/circular/dupe/dupe.html",
"chars": 884,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>requirejs: Cycle: Dupe Dependencies Test</title>\n <script type=\"text/javascr"
},
{
"path": "tests/circular/dupe/exported.js",
"chars": 240,
"preview": "define(function(require, exports) {\n exports.makeMessage = function (title) {\n return 'hello ' + title + ' ' +"
},
{
"path": "tests/circular/dupe/func.js",
"chars": 172,
"preview": "define(['exported'], function (exported) {\n function func(title) {\n return exported.makeMessage(title);\n }\n"
},
{
"path": "tests/circular/plugin.js",
"chars": 101,
"preview": "define({\n load: function (name, require, load, config) {\n require([name], load);\n }\n});\n"
},
{
"path": "tests/circular/transpiler/a.refine",
"chars": 103,
"preview": "refine(['refine!b', 'exports'], function (b, exports) {\n exports.name = 'a';\n exports.b = b;\n});\n"
},
{
"path": "tests/circular/transpiler/b.refine",
"chars": 103,
"preview": "refine(['refine!c', 'exports'], function (c, exports) {\n exports.name = 'b';\n exports.c = c;\n});\n"
},
{
"path": "tests/circular/transpiler/c.refine",
"chars": 103,
"preview": "refine(['refine!a', 'exports'], function (a, exports) {\n exports.name = 'c';\n exports.a = a;\n});\n"
},
{
"path": "tests/circular/transpiler/d.refine",
"chars": 135,
"preview": "define(['refine!e'], function(e) {\n function d() {\n return require('refine!e')();\n }\n\n d.name = 'd';\n\n "
},
{
"path": "tests/circular/transpiler/e.refine",
"chars": 147,
"preview": "define(['refine!d'], function(d) {\n function e() {\n return e.name + require('refine!d').name;\n }\n\n e.nam"
},
{
"path": "tests/circular/transpiler/transpiler-tests.js",
"chars": 731,
"preview": "require({\n baseUrl: requirejs.isBrowser ? './' : './circular/transpiler',\n paths: {\n 'text': '."
},
{
"path": "tests/circular/transpiler/transpiler.html",
"chars": 664,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Circular Transpiler Plugin Test</title>\n <script type=\"text/java"
},
{
"path": "tests/circular-tests.js",
"chars": 824,
"preview": "require({\n baseUrl: \"./\"\n },\n [\"require\", \"two\", \"funcTwo\", \"funcThree\"],\n function(require, two, funcTw"
},
{
"path": "tests/circular.html",
"chars": 455,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Circular Test</title>\n <script type=\"text/javascript\" src=\"../re"
},
{
"path": "tests/cjsSpace/a.js",
"chars": 176,
"preview": "define(function (require) {\n //Important, notice the space between require and arg calls\n var b = require ('b');\n\n"
},
{
"path": "tests/cjsSpace/b.js",
"chars": 27,
"preview": "define({\n name: 'b'\n});\n"
},
{
"path": "tests/cjsSpace/c.js",
"chars": 143,
"preview": "define(function (require) {\n if (typeof obj !== 'undefined') {\n obj.require('bad');\n }\n return {\n "
},
{
"path": "tests/cjsSpace/cjsDotRequire-tests.js",
"chars": 374,
"preview": "require({\n baseUrl: './'\n },\n ['a', 'c'],\n function(a, c) {\n doh.register(\n 'cjsDotReq"
},
{
"path": "tests/cjsSpace/cjsDotRequire.html",
"chars": 694,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Skipping false obj.require('') Test</title>\n <script type=\"text/"
},
{
"path": "tests/cjsSpace/cjsSpace-tests.js",
"chars": 317,
"preview": "require({\n baseUrl: './'\n },\n ['a'],\n function(a) {\n doh.register(\n 'cjsSpace',\n "
},
{
"path": "tests/cjsSpace/cjsSpace.html",
"chars": 652,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: ComonJS require ('') Test</title>\n <script type=\"text/javascript"
},
{
"path": "tests/commentParen/a.js",
"chars": 149,
"preview": "define(function (require) {\n var b = require ('b')// a comment right against the require\n\n return {\n name: "
},
{
"path": "tests/commentParen/b.js",
"chars": 27,
"preview": "define({\n name: 'b'\n});\n"
},
{
"path": "tests/commentParen/commentParen.html",
"chars": 990,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: commentParen Test</title>\n <script type=\"text/javascript\" src=\"."
},
{
"path": "tests/commonjs/tests/modules/1.0/absolute/b.js",
"chars": 112,
"preview": "define([\"require\", \"exports\", \"module\"], function(require, exports, module) {\nexports.foo = function() {};\n\n});\n"
},
{
"path": "tests/commonjs/tests/modules/1.0/absolute/program.html",
"chars": 419,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>Program Runner</title>\n <script src=\"../../../../../../require.js\"></script>"
},
{
"path": "tests/commonjs/tests/modules/1.0/absolute/program.js",
"chars": 298,
"preview": "define([\"require\", \"exports\", \"module\", \"test\",\"submodule/a\",\"b\"], function(require, exports, module) {\nvar test = requi"
},
{
"path": "tests/commonjs/tests/modules/1.0/absolute/submodule/a.js",
"chars": 144,
"preview": "define([\"require\", \"exports\", \"module\", \"b\"], function(require, exports, module) {\nexports.foo = function () {\n retur"
},
{
"path": "tests/commonjs/tests/modules/1.0/absolute/test.js",
"chars": 459,
"preview": "define([\"require\", \"exports\", \"module\", \"system\"], function(require, exports, module) {\n\nexports.print = typeof print !="
},
{
"path": "tests/commonjs/tests/modules/1.0/all.html",
"chars": 850,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>Links for Every Test</title>\n</head>\n<body>\n <h1>Links for Every Test</h1>\n "
},
{
"path": "tests/commonjs/tests/modules/1.0/cyclic/a.js",
"chars": 153,
"preview": "define([\"require\", \"exports\", \"module\", \"b\"], function(require, exports, module) {\nexports.a = function () {\n return "
},
{
"path": "tests/commonjs/tests/modules/1.0/cyclic/b.js",
"chars": 153,
"preview": "define([\"require\", \"exports\", \"module\", \"a\"], function(require, exports, module) {\nvar a = require('a');\nexports.b = fun"
},
{
"path": "tests/commonjs/tests/modules/1.0/cyclic/program.html",
"chars": 419,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>Program Runner</title>\n <script src=\"../../../../../../require.js\"></script>"
},
{
"path": "tests/commonjs/tests/modules/1.0/cyclic/program.js",
"chars": 344,
"preview": "define([\"require\", \"exports\", \"module\", \"test\",\"a\",\"b\"], function(require, exports, module) {\nvar test = require('test')"
},
{
"path": "tests/commonjs/tests/modules/1.0/cyclic/test.js",
"chars": 459,
"preview": "define([\"require\", \"exports\", \"module\", \"system\"], function(require, exports, module) {\n\nexports.print = typeof print !="
},
{
"path": "tests/commonjs/tests/modules/1.0/determinism/program.html",
"chars": 419,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>Program Runner</title>\n <script src=\"../../../../../../require.js\"></script>"
},
{
"path": "tests/commonjs/tests/modules/1.0/determinism/program.js",
"chars": 185,
"preview": "define([\"require\", \"exports\", \"module\", \"test\",\"submodule/a\"], function(require, exports, module) {\nvar test = require('"
},
{
"path": "tests/commonjs/tests/modules/1.0/determinism/submodule/a.js",
"chars": 343,
"preview": "define([\"require\", \"exports\", \"module\", \"test\",\"test\",\"a\"], function(require, exports, module) {\nvar test = require('tes"
},
{
"path": "tests/commonjs/tests/modules/1.0/determinism/submodule/b.js",
"chars": 85,
"preview": "define([\"require\", \"exports\", \"module\"], function(require, exports, module) {\n\n\n\n});\n"
},
{
"path": "tests/commonjs/tests/modules/1.0/determinism/test.js",
"chars": 459,
"preview": "define([\"require\", \"exports\", \"module\", \"system\"], function(require, exports, module) {\n\nexports.print = typeof print !="
},
{
"path": "tests/commonjs/tests/modules/1.0/exactExports/a.js",
"chars": 160,
"preview": "define([\"require\", \"exports\", \"module\", \"program\"], function(require, exports, module) {\nexports.program = function () {"
},
{
"path": "tests/commonjs/tests/modules/1.0/exactExports/program.html",
"chars": 419,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>Program Runner</title>\n <script src=\"../../../../../../require.js\"></script>"
},
{
"path": "tests/commonjs/tests/modules/1.0/exactExports/program.js",
"chars": 228,
"preview": "define([\"require\", \"exports\", \"module\", \"test\",\"a\"], function(require, exports, module) {\nvar test = require('test');\nva"
},
{
"path": "tests/commonjs/tests/modules/1.0/exactExports/test.js",
"chars": 459,
"preview": "define([\"require\", \"exports\", \"module\", \"system\"], function(require, exports, module) {\n\nexports.print = typeof print !="
},
{
"path": "tests/commonjs/tests/modules/1.0/hasOwnProperty/hasOwnProperty.js",
"chars": 83,
"preview": "define([\"require\", \"exports\", \"module\"], function(require, exports, module) {\n\n});\n"
},
{
"path": "tests/commonjs/tests/modules/1.0/hasOwnProperty/program.html",
"chars": 419,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>Program Runner</title>\n <script src=\"../../../../../../require.js\"></script>"
},
{
"path": "tests/commonjs/tests/modules/1.0/hasOwnProperty/program.js",
"chars": 259,
"preview": "define([\"require\", \"exports\", \"module\", \"hasOwnProperty\",\"toString\",\"test\"], function(require, exports, module) {\nvar ha"
},
{
"path": "tests/commonjs/tests/modules/1.0/hasOwnProperty/test.js",
"chars": 459,
"preview": "define([\"require\", \"exports\", \"module\", \"system\"], function(require, exports, module) {\n\nexports.print = typeof print !="
},
{
"path": "tests/commonjs/tests/modules/1.0/hasOwnProperty/toString.js",
"chars": 83,
"preview": "define([\"require\", \"exports\", \"module\"], function(require, exports, module) {\n\n});\n"
},
{
"path": "tests/commonjs/tests/modules/1.0/method/a.js",
"chars": 288,
"preview": "define([\"require\", \"exports\", \"module\"], function(require, exports, module) {\nexports.foo = function () {\n return thi"
},
{
"path": "tests/commonjs/tests/modules/1.0/method/program.html",
"chars": 419,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>Program Runner</title>\n <script src=\"../../../../../../require.js\"></script>"
},
{
"path": "tests/commonjs/tests/modules/1.0/method/program.js",
"chars": 381,
"preview": "define([\"require\", \"exports\", \"module\", \"test\",\"a\"], function(require, exports, module) {\nvar test = require('test');\nva"
},
{
"path": "tests/commonjs/tests/modules/1.0/method/test.js",
"chars": 459,
"preview": "define([\"require\", \"exports\", \"module\", \"system\"], function(require, exports, module) {\n\nexports.print = typeof print !="
},
{
"path": "tests/commonjs/tests/modules/1.0/missing/program.html",
"chars": 419,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>Program Runner</title>\n <script src=\"../../../../../../require.js\"></script>"
},
{
"path": "tests/commonjs/tests/modules/1.0/missing/program.js",
"chars": 353,
"preview": "define([\"require\", \"exports\", \"module\", \"test\",\"bogus\"], function(require, exports, module) {\nvar test = require('test')"
},
{
"path": "tests/commonjs/tests/modules/1.0/missing/test.js",
"chars": 459,
"preview": "define([\"require\", \"exports\", \"module\", \"system\"], function(require, exports, module) {\n\nexports.print = typeof print !="
},
{
"path": "tests/commonjs/tests/modules/1.0/monkeys/a.js",
"chars": 126,
"preview": "define([\"require\", \"exports\", \"module\", \"program\"], function(require, exports, module) {\nrequire('program').monkey = 10;"
},
{
"path": "tests/commonjs/tests/modules/1.0/monkeys/program.html",
"chars": 419,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>Program Runner</title>\n <script src=\"../../../../../../require.js\"></script>"
},
{
"path": "tests/commonjs/tests/modules/1.0/monkeys/program.js",
"chars": 229,
"preview": "define([\"require\", \"exports\", \"module\", \"a\",\"test\"], function(require, exports, module) {\nvar a = require('a');\nvar test"
},
{
"path": "tests/commonjs/tests/modules/1.0/monkeys/test.js",
"chars": 459,
"preview": "define([\"require\", \"exports\", \"module\", \"system\"], function(require, exports, module) {\n\nexports.print = typeof print !="
},
{
"path": "tests/commonjs/tests/modules/1.0/nested/a/b/c/d.js",
"chars": 128,
"preview": "define([\"require\", \"exports\", \"module\"], function(require, exports, module) {\nexports.foo = function () {\n return 1;\n"
},
{
"path": "tests/commonjs/tests/modules/1.0/nested/program.html",
"chars": 419,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>Program Runner</title>\n <script src=\"../../../../../../require.js\"></script>"
},
{
"path": "tests/commonjs/tests/modules/1.0/nested/program.js",
"chars": 229,
"preview": "define([\"require\", \"exports\", \"module\", \"test\",\"a/b/c/d\"], function(require, exports, module) {\nvar test = require('test"
},
{
"path": "tests/commonjs/tests/modules/1.0/nested/test.js",
"chars": 459,
"preview": "define([\"require\", \"exports\", \"module\", \"system\"], function(require, exports, module) {\n\nexports.print = typeof print !="
},
{
"path": "tests/commonjs/tests/modules/1.0/relative/program.html",
"chars": 419,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>Program Runner</title>\n <script src=\"../../../../../../require.js\"></script>"
},
{
"path": "tests/commonjs/tests/modules/1.0/relative/program.js",
"chars": 316,
"preview": "define([\"require\", \"exports\", \"module\", \"test\",\"submodule/a\",\"submodule/b\"], function(require, exports, module) {\nvar te"
},
{
"path": "tests/commonjs/tests/modules/1.0/relative/submodule/a.js",
"chars": 124,
"preview": "define([\"require\", \"exports\", \"module\", \"./b\"], function(require, exports, module) {\nexports.foo = require('./b').foo;\n\n"
},
{
"path": "tests/commonjs/tests/modules/1.0/relative/submodule/b.js",
"chars": 114,
"preview": "define([\"require\", \"exports\", \"module\"], function(require, exports, module) {\nexports.foo = function () {\n};\n\n});\n"
},
{
"path": "tests/commonjs/tests/modules/1.0/relative/test.js",
"chars": 459,
"preview": "define([\"require\", \"exports\", \"module\", \"system\"], function(require, exports, module) {\n\nexports.print = typeof print !="
},
{
"path": "tests/commonjs/tests/modules/1.0/system.js",
"chars": 150,
"preview": "define({\n stdio: {\n //Funky list args to appease Safari\n print: function (a, b) {\n console.l"
},
{
"path": "tests/commonjs/tests/modules/1.0/test.js",
"chars": 418,
"preview": "define([\"require\", \"exports\", \"module\", \"system\"], function(require, exports, module) {\n\nexports.print = function () {\n "
},
{
"path": "tests/commonjs/tests/modules/1.0/transitive/a.js",
"chars": 120,
"preview": "define([\"require\", \"exports\", \"module\", \"b\"], function(require, exports, module) {\nexports.foo = require('b').foo;\n\n});\n"
},
{
"path": "tests/commonjs/tests/modules/1.0/transitive/b.js",
"chars": 120,
"preview": "define([\"require\", \"exports\", \"module\", \"c\"], function(require, exports, module) {\nexports.foo = require('c').foo;\n\n});\n"
},
{
"path": "tests/commonjs/tests/modules/1.0/transitive/c.js",
"chars": 128,
"preview": "define([\"require\", \"exports\", \"module\"], function(require, exports, module) {\nexports.foo = function () {\n return 1;\n"
},
{
"path": "tests/commonjs/tests/modules/1.0/transitive/program.html",
"chars": 419,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>Program Runner</title>\n <script src=\"../../../../../../require.js\"></script>"
},
{
"path": "tests/commonjs/tests/modules/1.0/transitive/program.js",
"chars": 203,
"preview": "define([\"require\", \"exports\", \"module\", \"test\",\"a\"], function(require, exports, module) {\nvar test = require('test');\nte"
},
{
"path": "tests/commonjs/tests/modules/1.0/transitive/test.js",
"chars": 459,
"preview": "define([\"require\", \"exports\", \"module\", \"system\"], function(require, exports, module) {\n\nexports.print = typeof print !="
},
{
"path": "tests/config.html",
"chars": 1455,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Config Test</title>\n <script type=\"text/javascript\" src=\"doh/run"
},
{
"path": "tests/configRequirejs.html",
"chars": 1596,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Config requirejs Test</title>\n <script type=\"text/javascript\" sr"
},
{
"path": "tests/dataMain/baseUrl/a.js",
"chars": 28,
"preview": "define({\n name: 'a'\n});\n\n"
},
{
"path": "tests/dataMain/baseUrl/dataMainBaseUrl.html",
"chars": 698,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: data-main baseUrl Test</title>\n <script type=\"text/javascript\" s"
},
{
"path": "tests/dataMain/baseUrl/src/main.js",
"chars": 210,
"preview": "define(['a'], function (a) {\n doh.register(\n \"dataMainBaseUrl\",\n [\n function dataMainBaseUrl"
},
{
"path": "tests/dataMain/dataMain.html",
"chars": 421,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: data-main Test</title>\n <script type=\"text/javascript\" src=\"../d"
},
{
"path": "tests/dataMain/dataMain.js",
"chars": 316,
"preview": "require({\n baseUrl: \"../\"\n },\n [\"require\", \"simple\"],\n function(require, simple) {\n doh.register("
},
{
"path": "tests/dataMain/dataMainIndex/dataMainIndex.html",
"chars": 767,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: data-main index Test</title>\n <script type=\"text/javascript\" src"
},
{
"path": "tests/dataMain/dataMainIndex/index.js",
"chars": 248,
"preview": "define('a', {\n name: 'a'\n});\n\ndefine('index', ['a'], function (a) {\n doh.register(\n \"dataMainIndex\",\n "
},
{
"path": "tests/dataMain/dataMainPlugin/dataMainPlugin.html",
"chars": 602,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: data-main plugin Test</title>\n <script type=\"text/javascript\" sr"
},
{
"path": "tests/dataMain/dataMainPlugin/modules/sub/a.js",
"chars": 27,
"preview": "define({\n name: 'a'\n});\n"
},
{
"path": "tests/dataMain/dataMainPlugin/modules/sub/test.js",
"chars": 210,
"preview": "define(['./a'], function (a) {\n doh.register(\n \"dataMainPlugin\",\n [\n function dataMainPlugin"
},
{
"path": "tests/dataMain/dataMainPlugin/my/plugin.js",
"chars": 151,
"preview": "define({\n load: function( name, req, onload, config ) {\n requirejs.config({ baseUrl: './modules' });\n "
},
{
"path": "tests/dataMain/skipDataMain/a.js",
"chars": 28,
"preview": "define({\n name: 'a'\n});\n\n"
},
{
"path": "tests/dataMain/skipDataMain/index.js",
"chars": 65,
"preview": "define('index', ['a'], function (a) {\n a.modified = true;\n});\n"
},
{
"path": "tests/dataMain/skipDataMain/skipDataMain.html",
"chars": 1187,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Skip data-main Test</title>\n <script type=\"text/javascript\" src="
},
{
"path": "tests/datauri/datauri.html",
"chars": 924,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: data: uri Tests</title>\n <script type=\"text/javascript\" src=\"../"
},
{
"path": "tests/defineDouble/defineDouble.html",
"chars": 1286,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Define Double Test</title>\n <script src=\"../doh/runner.js\"></scr"
},
{
"path": "tests/definedSpecified/a.js",
"chars": 27,
"preview": "define({\n name: 'a'\n});\n"
},
{
"path": "tests/definedSpecified/b.js",
"chars": 27,
"preview": "define({\n name: 'b'\n});\n"
},
{
"path": "tests/definedSpecified/definedSpecified-tests.js",
"chars": 669,
"preview": "/*global doh */\nvar master = new doh.Deferred();\n//Register the test\ndoh.register(\n \"definedSpecified\",\n [\n "
},
{
"path": "tests/definedSpecified/definedSpecified.html",
"chars": 638,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Defined Specified Test</title>\n <script type=\"text/javascript\" s"
},
{
"path": "tests/delayedDefine/delayedDefine-tests.js",
"chars": 1080,
"preview": "var globals = {};\nvar master = new doh.Deferred();\n\ndefine('a', ['b'], function (b) {\n globals.a = 'a';\n});\n\ndefine('"
},
{
"path": "tests/delayedDefine/delayedDefine.html",
"chars": 652,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Delayed Define Test</title>\n <script type=\"text/javascript\" src="
},
{
"path": "tests/depEmpty.html",
"chars": 1188,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Empty Dependency Test</title>\n <script type=\"text/javascript\" sr"
},
{
"path": "tests/depoverlap.html",
"chars": 569,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: Dependency Overlap Test</title>\n <script type=\"text/javascript\" "
},
{
"path": "tests/depoverlap.js",
"chars": 1200,
"preview": "require([\"require\", \"uno\"],\nfunction (require, uno) {\n doh.register(\n \"depoverlap\",\n [\n fu"
},
{
"path": "tests/dimple.js",
"chars": 86,
"preview": "//\n// this is a comment\n//\ndefine(\"dimple\",\n {\n color: \"dimple-blue\"\n }\n);\n"
},
{
"path": "tests/doh/LICENSE",
"chars": 11345,
"preview": "Dojo is available under *either* the terms of the modified BSD license *or* the\nAcademic Free License version 2.1. As a "
},
{
"path": "tests/doh/README",
"chars": 512,
"preview": "DOH may be run standalone by issuing a command like the following:\n\njava -jar ../shrinksafe/js.jar runner.js testModule="
},
{
"path": "tests/doh/_browserRunner.js",
"chars": 24959,
"preview": "if(window[\"dojo\"]){\n\tdojo.provide(\"doh._browserRunner\");\n}\n\n// FIXME: need to add prompting for monkey-do testing\n\n(func"
},
{
"path": "tests/doh/_nodeRunner.js",
"chars": 527,
"preview": "\n/*global doh: false, process: false */\n\nvar aps = Array.prototype.slice;\n\ndoh.debug = function () {\n //Could have mu"
},
{
"path": "tests/doh/_rhinoRunner.js",
"chars": 371,
"preview": "if(this[\"dojo\"]){\n\tdojo.provide(\"doh._rhinoRunner\");\n}\n\ndoh.debug = print;\n\n// Override the doh._report method to make i"
},
{
"path": "tests/doh/_sounds/LICENSE",
"chars": 342,
"preview": "License Disclaimer:\n\nAll contents of this directory are Copyright (c) the Dojo Foundation, with the\nfollowing exceptions"
},
{
"path": "tests/doh/runner.html",
"chars": 7893,
"preview": "<html>\n\t<!--\n\t\tNOTE: we are INTENTIONALLY in quirks mode. It makes it much easier to\n\t\tget a \"full screen\" UI w/ straigh"
},
{
"path": "tests/doh/runner.js",
"chars": 45181,
"preview": "// package system gunk.\n//try{\n//\tdojo.provide(\"doh.runner\");\n//}catch(e){\n\tif(!this[\"doh\"]){\n\t\tdoh = {};\n\t}\n//}\n\n//\n// "
},
{
"path": "tests/doh/runner.sh",
"chars": 65,
"preview": "#!/bin/sh\n\njava -jar ../../build/lib/rhino/js.jar runner.js \"$@\"\n"
},
{
"path": "tests/domReady/domReady-tests.js",
"chars": 1049,
"preview": "/*jslint */\n/*global requirejs: false, doh: false, document: false */\n\nrequirejs.config({\n paths: {\n domReady:"
},
{
"path": "tests/domReady/domReady.html",
"chars": 423,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: domReady Test</title>\n <script type=\"text/javascript\" src=\"../do"
},
{
"path": "tests/domReady/domReadyExtraConfig-tests.js",
"chars": 829,
"preview": "/*jslint */\n/*global requirejs: false, doh: false, document: false */\n\nrequirejs.config({\n paths: {\n domReady:"
},
{
"path": "tests/domReady/domReadyExtraConfig.html",
"chars": 555,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>require.js: domReady Extra Config Test</title>\n <script type=\"text/javascrip"
}
]
// ... and 444 more files (download for full content)
About this extraction
This page contains the full source code of the requirejs/requirejs GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 644 files (1.1 MB), approximately 298.2k tokens, and a symbol index with 77 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.