You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api.html
+5-30Lines changed: 5 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -629,15 +629,15 @@ <h3><a name="packages">Loading Modules from Packages</a><span class="sectionMark
629
629
<ul>
630
630
<li><strong>name</strong>: The name of the package (used for the module name/prefix mapping)</li>
631
631
<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>
632
-
<li><strong>lib</strong>: The name of the directory inside the package folder that contains modules. The default value is "lib", so no need to specify it unless it is different than the default.</li>
633
-
<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 "lib/main", so only specify it if it differs from the default. The value is relative to the package folder.</li>
632
+
<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>
634
633
</ul></li>
635
634
</ul>
636
635
637
636
<p><strong>IMPORTANT NOTES</strong></p>
638
637
639
638
<ul>
640
639
<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 <ahref="commonjs.html#autoconversion">CommonJS converter tool</a> if you need to convert traditional CommonJS modules into the async module format that RequireJS uses.</li>
640
+
<li>The <strong>lib</strong> directory option that may be used in packages is not supported. It causes some confusing path issues.</li>
641
641
<li>Only one version of a package can be used in a project context at a time. You can use RequireJS <ahref="#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>
642
642
</ul>
643
643
@@ -671,34 +671,22 @@ <h3><a name="packages">Loading Modules from Packages</a><span class="sectionMark
671
671
<ul>
672
672
<li>alpha/
673
673
<ul>
674
-
<li>lib/
675
-
<ul>
676
674
<li>main.js</li>
677
675
</ul></li>
678
-
</ul></li>
679
676
<li>omega/
680
677
<ul>
681
-
<li>lib/
682
-
<ul>
683
678
<li>main.js</li>
684
679
</ul></li>
685
680
</ul></li>
686
-
</ul></li>
687
681
<li>cart/
688
682
<ul>
689
-
<li>lib/
690
-
<ul>
691
683
<li>main.js</li>
692
684
</ul></li>
693
-
</ul></li>
694
685
<li>store/
695
686
<ul>
696
-
<li>lib/
697
-
<ul>
698
687
<li>main.js</li>
699
688
<li>util.js</li>
700
689
</ul></li>
701
-
</ul></li>
702
690
<li>main.js</li>
703
691
<li>package.json</li>
704
692
<li>require.js</li>
@@ -738,9 +726,9 @@ <h3><a name="packages">Loading Modules from Packages</a><span class="sectionMark
738
726
});
739
727
</code></pre>
740
728
741
-
<p>A require of "alpha" means that it will be loaded from <strong>scripts/.packages/alpha/lib/main.js</strong>, since "lib" and "main" are the default lib directory and main module settings supported by RequireJS. A require of "store/util" will be loaded from <strong>scripts/store/lib/util.js</strong>.</p>
729
+
<p>A require of "alpha" means that it will be loaded from <strong>scripts/.packages/alpha/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>
742
730
743
-
<p>If the "alpha" and "store" packages did not follow the "lib" and "main.js" conventions, and looked more like this:</p>
731
+
<p>If the "alpha" and "store" packages did not follow the "main.js" convention, and looked more like this:</p>
744
732
745
733
<ul>
746
734
<li>project-directory/
@@ -753,26 +741,17 @@ <h3><a name="packages">Loading Modules from Packages</a><span class="sectionMark
753
741
<ul>
754
742
<li>alpha/
755
743
<ul>
756
-
<li>scripts/
757
-
<ul>
758
744
<li>index.js</li>
759
745
</ul></li>
760
-
</ul></li>
761
746
<li>omega/
762
747
<ul>
763
-
<li>lib/
764
-
<ul>
765
748
<li>main.js</li>
766
749
</ul></li>
767
750
</ul></li>
768
-
</ul></li>
769
751
<li>cart/
770
752
<ul>
771
-
<li>lib/
772
-
<ul>
773
753
<li>main.js</li>
774
754
</ul></li>
775
-
</ul></li>
776
755
<li>store/
777
756
<ul>
778
757
<li>store.js</li>
@@ -792,7 +771,6 @@ <h3><a name="packages">Loading Modules from Packages</a><span class="sectionMark
792
771
".packages": [
793
772
{
794
773
name: "alpha",
795
-
lib: "scripts",
796
774
main: "index"
797
775
},
798
776
"omega"
@@ -802,7 +780,6 @@ <h3><a name="packages">Loading Modules from Packages</a><span class="sectionMark
802
780
"cart",
803
781
{
804
782
name: "store",
805
-
lib: ".",
806
783
main: "store"
807
784
}
808
785
]
@@ -816,7 +793,6 @@ <h3><a name="packages">Loading Modules from Packages</a><span class="sectionMark
816
793
{
817
794
name: "alpha",
818
795
location: ".packages/alpha",
819
-
lib: "scripts",
820
796
main: "index"
821
797
},
822
798
{
@@ -826,14 +802,13 @@ <h3><a name="packages">Loading Modules from Packages</a><span class="sectionMark
826
802
"cart",
827
803
{
828
804
name: "store",
829
-
lib: ".",
830
805
main: "store"
831
806
}
832
807
]
833
808
});
834
809
</code></pre>
835
810
836
-
<p>To avoid verbosity, it is strongly suggested to always use packages that use the "lib" and "main" conventions in their structure, and use packagePaths for third party packages.</p>
811
+
<p>To avoid verbosity, it is strongly suggested to always use packages that use "main" convention in their structure, and use packagePaths for third party packages.</p>
837
812
838
813
<p>To make fetching and configuring packages easier, there are designs for a command line package tool in the works.</p>
0 commit comments