Browse Source

Clean amber.js, move RequireJS config piece to load sets.

Looser coupling, helps to separate parts.
Herbert Vojčík 10 years ago
parent
commit
6c09e4c0ba
7 changed files with 102 additions and 63 deletions
  1. 1 23
      support/amber.js
  2. 12 0
      support/codemirror-inner.js
  3. 15 8
      support/codemirror.js
  4. 11 0
      support/devel-inner.js
  5. 16 6
      support/devel.js
  6. 27 0
      support/helios-inner.js
  7. 20 26
      support/helios.js

+ 1 - 23
support/amber.js

@@ -64,8 +64,7 @@ require = function (require) {
             'amber_lib': library_home,
             'amber_core': amber_home + '/src',
             'amber_helios/html': amber_home,
-            'jquery': library_home + '/jquery/jquery.min',
-            'jquery-ui': library_home + '/jquery-ui/ui/minified/jquery-ui.min'
+            'jquery': library_home + '/jquery/jquery.min'
         },
         map: {
             '*': {
@@ -73,27 +72,6 @@ require = function (require) {
             }
         },
         shim: {
-            'jquery-ui': {
-                deps: [ 'jquery' ]
-            },
-            'amber_lib/bootstrap/js/bootstrap': {
-                deps: [ 'jquery', 'css!amber_lib/bootstrap/css/bootstrap' ]
-            },
-            'amber_lib/codemirror/lib/codemirror': {
-                deps: [ 'css!amber_lib/codemirror/lib/codemirror' ]
-            },
-            'amber_lib/jquery-tabby/jquery.textarea': {
-                deps: [ 'jquery' ]
-            },
-            'amber_core/IDE': {
-                deps: [ 'amber_lib/codemirror/mode/smalltalk/smalltalk' ]
-            },
-            'amber_lib/codemirror/mode/smalltalk/smalltalk': {
-                deps: [ '../../lib/codemirror' ]
-            },
-            'amber_lib/codemirror/addon/hint/show-hint': {
-                deps: [ '../../lib/codemirror' ]
-            },
             'ensure-console': {
                 exports: 'console'
             }

+ 12 - 0
support/codemirror-inner.js

@@ -0,0 +1,12 @@
+// Loading this in nested file so that require.config
+// with shim dependencies is in effect.
+// See http://stackoverflow.com/questions/21647956/how-to-config-requirejs-shim-dependencies-just-in-time/
+
+define([
+    'amber_lib/codemirror/lib/codemirror',
+    'amber_lib/codemirror/mode/smalltalk/smalltalk',
+    'amber_lib/codemirror/addon/hint/show-hint',
+    'css!amber_lib/codemirror/theme/ambiance',
+    'css!amber_lib/codemirror/lib/codemirror',
+    'css!amber_lib/codemirror/addon/hint/show-hint'
+]);

+ 15 - 8
support/codemirror.js

@@ -1,8 +1,15 @@
-define([
-		'amber_lib/codemirror/lib/codemirror',
-		'amber_lib/codemirror/mode/smalltalk/smalltalk',
-		'amber_lib/codemirror/addon/hint/show-hint',
-		'css!amber_lib/codemirror/theme/ambiance',
-		'css!amber_lib/codemirror/lib/codemirror',
-		'css!amber_lib/codemirror/addon/hint/show-hint'
-]);
+require.config({
+	shim: {
+		'amber_lib/codemirror/lib/codemirror': {
+			deps: [ 'css!amber_lib/codemirror/lib/codemirror' ]
+		},
+		'amber_lib/codemirror/mode/smalltalk/smalltalk': {
+			deps: [ '../../lib/codemirror' ]
+		},
+		'amber_lib/codemirror/addon/hint/show-hint': {
+			deps: [ '../../lib/codemirror' ]
+		}
+	}
+});
+
+define(['./codemirror-inner']);

+ 11 - 0
support/devel-inner.js

@@ -0,0 +1,11 @@
+// Loading this in nested file so that require.config
+// with shim dependencies is in effect.
+// See http://stackoverflow.com/questions/21647956/how-to-config-requirejs-shim-dependencies-just-in-time/
+
+define([
+	'jquery-ui',
+    'amber_lib/jquery-tabby/jquery.textarea',
+    'amber_core/IDE',
+    'amber_core/Examples',
+    'amber_core/Benchfib'
+]);

+ 16 - 6
support/devel.js

@@ -1,12 +1,22 @@
+require.config({
+	paths: {
+		'jquery-ui': require.toUrl('amber_lib/jquery-ui/ui/minified/jquery-ui.min')
+	},
+	shim: {
+		'jquery-ui': {
+			deps: [ 'jquery' ]
+		},
+		'amber_lib/jquery-tabby/jquery.textarea': {
+			deps: [ 'jquery' ]
+		}
+	}
+});
+
 define([
 	'./helpers', // pre-fetch, dep of ./deploy
 	'./deploy', // pre-fetch, dep of ./lang
 	'./lang',
-	'jquery-ui',
-	'amber_lib/jquery-tabby/jquery.textarea',
 	'./codemirror',
-	'css!amber_css/amber',
-	'amber_core/IDE',
-	'amber_core/Examples',
-	'amber_core/Benchfib'
+	'./devel-inner',
+	'css!amber_css/amber'
 ], function (smalltalk) { return smalltalk; });

+ 27 - 0
support/helios-inner.js

@@ -0,0 +1,27 @@
+// Loading this in nested file so that require.config
+// with shim dependencies is in effect.
+// See http://stackoverflow.com/questions/21647956/how-to-config-requirejs-shim-dependencies-just-in-time/
+
+define([
+	'./devel-inner',
+	'amber_lib/bootstrap/js/bootstrap',
+	'amber_lib/showdown/compressed/showdown',
+	'amber_core/Spaces',
+	'amber_core/Helios-Core',
+	'amber_core/Helios-Exceptions',
+	'amber_core/Helios-Helpers',
+	'amber_core/Helios-Commands-Core',
+	'amber_core/Helios-Commands-Tools',
+	'amber_core/Helios-Commands-Browser',
+	'amber_core/Helios-Layout',
+	'amber_core/Helios-KeyBindings',
+	'amber_core/Helios-Browser',
+	'amber_core/Helios-Workspace',
+	'amber_core/Helios-Transcript',
+	'amber_core/Helios-SUnit',
+	'amber_core/Helios-Debugger',
+	'amber_core/Helios-Inspector',
+	'amber_core/Helios-References',
+	'amber_core/Helios-Announcements',
+	'amber_core/Helios-Workspace-Tests'
+]);

+ 20 - 26
support/helios.js

@@ -1,32 +1,26 @@
+require.config({
+	paths: {
+		'jquery-ui': require.toUrl('amber_lib/jquery-ui/ui/minified/jquery-ui.min')
+	},
+	shim: {
+		'jquery-ui': {
+			deps: [ 'jquery' ]
+		},
+		'amber_lib/bootstrap/js/bootstrap': {
+			deps: [ 'jquery', 'css!amber_lib/bootstrap/css/bootstrap' ]
+		},
+		'amber_lib/jquery-tabby/jquery.textarea': {
+			deps: [ 'jquery' ]
+		}
+	}
+});
+
 define([
 	'./helpers', // pre-fetch, dep of ./deploy
 	'./deploy', // pre-fetch, dep of ./lang
 	'./lang',
-	'jquery-ui',
-	'amber_lib/jquery-tabby/jquery.textarea',
-	'amber_lib/bootstrap/js/bootstrap',
-	'amber_lib/showdown/compressed/showdown',
 	'./codemirror',
-	'css!amber_css/helios',
-	'amber_core/IDE',
-	'amber_core/Examples',
-	'amber_core/Benchfib',
-	'amber_core/Spaces',
-	'amber_core/Helios-Core',
-	'amber_core/Helios-Exceptions',
-	'amber_core/Helios-Helpers',
-	'amber_core/Helios-Commands-Core',
-	'amber_core/Helios-Commands-Tools',
-	'amber_core/Helios-Commands-Browser',
-	'amber_core/Helios-Layout',
-	'amber_core/Helios-KeyBindings',
-	'amber_core/Helios-Browser',
-	'amber_core/Helios-Workspace',
-	'amber_core/Helios-Transcript',
-	'amber_core/Helios-SUnit',
-	'amber_core/Helios-Debugger',
-	'amber_core/Helios-Inspector',
-	'amber_core/Helios-References',
-	'amber_core/Helios-Announcements',
-	'amber_core/Helios-Workspace-Tests'
+	'./devel-inner', // pre-fetch, dep of ./helios-inner
+	'./helios-inner',
+	'css!amber_css/helios'
 ], function (smalltalk) { return smalltalk; });