Browse Source

Polyfills loaded explicitly.

'amber/compatibility' not used,
nulled for bw compatibility with kernel that still loads it.
Herbert Vojčík 7 years ago
parent
commit
9dd969b53f
4 changed files with 43 additions and 27 deletions
  1. 33 12
      root/Gruntfile.js
  2. 0 1
      root/config-browser.js
  3. 0 6
      root/config-node.js
  4. 10 8
      root/index.html

+ 33 - 12
root/Gruntfile.js

@@ -51,15 +51,22 @@ module.exports = function (grunt) {
                 options: {
                     mainConfigFile: "config.js",
                     rawText: {
-                        "amber/compatibility": "/*stub*/",
-                        "amber/Platform": "define()", //eg. nothing, TODO remove
-                        "app": 'define(["deploy", "amber_core/Platform-Browser"],function(x){return x});'
+                        "amber/compatibility": "/* stub */", //eg. nothing, TODO remove
+                        "amber/Platform": "/* stub */", //eg. nothing, TODO remove
+                        "app": '(' + function () {
+                            define(["require", "amber/es2015-polyfills"], function (require) {
+                                return new Promise(function (resolve, reject) {
+                                    require(["__app__"], resolve, reject);
+                                });
+                            });
+                        } + '());',
+                        "__app__": 'define(["deploy", "amber_core/Platform-Browser"],function(x){return x});'
                     },
                     pragmas: {
                         excludeIdeData: true,
                         excludeDebugContexts: true
                     },
-                    include: ['config', 'config-browser', 'amber/Platform' /*TODO remove*/, 'node_modules/requirejs/require', 'app', 'amber/lazypack'],
+                    include: ['config', 'node_modules/requirejs/require', 'app', 'amber/lazypack', '__app__'],
                     optimize: "uglify2",
                     out: "the.js"
                 }
@@ -68,12 +75,19 @@ module.exports = function (grunt) {
                 options: {
                     mainConfigFile: "config.js",
                     rawText: {
-                        "amber/compatibility": "/*stub*/",
-                        "amber/Platform": "define()", //eg. nothing, TODO remove
-                        "amber_core/_platform_HaX_": "require.config({map:{'*':{'amber/Platform':'app'}}});", // TODO remove
-                        "app": 'define(["devel", "amber_core/Platform-Browser"],function(x){return x});'
+                        "amber/compatibility": "/* stub */", //eg. nothing, TODO remove
+                        "amber/Platform": "/* stub */", //eg. nothing, TODO remove
+                        "amber_core/_HaX_": "require.config({map:{'*':{'amber/Platform':'app','amber/compatibility':'app'}}});", // TODO remove
+                        "app": '(' + function () {
+                            define(["require", "amber/es2015-polyfills"], function (require) {
+                                return new Promise(function (resolve, reject) {
+                                    require(["__app__"], resolve, reject);
+                                });
+                            });
+                        } + '());',
+                        "__app__": 'define(["devel", "amber_core/Platform-Browser"],function(x){return x});'
                     },
-                    include: ['config', 'config-browser', 'amber_core/_platform_HaX_' /*TODO remove*/, 'node_modules/requirejs/require', 'app'],
+                    include: ['config', 'amber_core/_HaX_' /*TODO remove*/, 'node_modules/requirejs/require', 'app', '__app__'],
                     exclude: ['devel'],
                     out: "the.js"
                 }
@@ -82,20 +96,27 @@ module.exports = function (grunt) {
                 options: {
                     mainConfigFile: "config.js",
                     rawText: {
-                        "amber/Platform": "define()", //eg. nothing, TODO remove
-                        "app": "(" + function () {
+                        "jquery": "/* do not load in node test runner */",
+                        "amber/compatibility": "/* stub */", //eg. nothing, TODO remove
+                        "amber/Platform": "/* stub */", //eg. nothing, TODO remove
+                        "__app__": "(" + function () {
                             define(["testing", "amber_core/Platform-Node", "amber_devkit/NodeTestRunner"], function (amber) {
                                 amber.initialize().then(function () {
                                     amber.globals.NodeTestRunner._main();
                                 });
                             });
+                        } + "());",
+                        "app": "(" + function () {
+                            define(["require", "amber/es2015-polyfills"], function () {
+                                require(["__app__"]);
+                            });
                         } + "());"
                     },
                     paths: {"amber_devkit": helpers.libPath},
                     pragmas: {
                         excludeIdeData: true
                     },
-                    include: ['config-node', 'app', 'amber/lazypack'],
+                    include: ['app', 'amber/lazypack', '__app__'],
                     insertRequire: ['app'],
                     optimize: "none",
                     wrap: helpers.nodeWrapperWithShebang,

+ 0 - 1
root/config-browser.js

@@ -1 +0,0 @@
-define("amber/compatibility", ["amber/browser-compatibility"], {});

+ 0 - 6
root/config-node.js

@@ -1,6 +0,0 @@
-// This file is used to make additional changes
-// when building an app to run in node.js.
-// Free to edit. You can break tests (cli test runner uses
-// this to build itself - it is a node executable).
-define("amber/compatibility", ["amber/node-compatibility"], {});
-define("jquery", {});

+ 10 - 8
root/index.html

@@ -21,15 +21,17 @@
 <ol id="output-list"></ol>
 <!-- EXAMPLE APP END -->
 <script type='text/javascript'>
-    require(['app'], function (amber) {
-        amber.initialize({
-            //used for all new packages in IDE
-            'transport.defaultAmdNamespace': "{%= namespace %}"
-        }).then(function () {
-            require(["amber-ide-starter-dialog"], function (dlg) {
-                dlg.start();
+    require(['app'], function (amberPromise) {
+        amberPromise.then(function (amber) {
+            amber.initialize({
+                //used for all new packages in IDE
+                'transport.defaultAmdNamespace': "{%= namespace %}"
+            }).then(function () {
+                require(["amber-ide-starter-dialog"], function (dlg) {
+                    dlg.start();
+                });
+                amber.globals.{%= name %}._start();
             });
-            amber.globals.{%= name %}._start();
         });
     });
 </script>