Просмотр исходного кода

Keep CodeMirror out of the Node test runner.

test_runner.js died at load with "document is not defined": the shim
makes CodeMirror depend on its stylesheet, which require-css inlines
behind an injector that writes a style element, and CodeMirror itself
reads document as it loads.

CodeMirror and its two add-ons are stubbed as jquery is. The stub calls
define itself, so r.js does not give it the shim's css! dependency,
which amdefine could not load; the stylesheet the shim still pulls in
is excluded from the build. The stub carries the keyMap and commands
that HLCodeWidget class sets up when its package loads, and is a
function, as CodeMirror is, so that Amber answers basicAt: on it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Herby Vojčík 1 день назад
Родитель
Сommit
42f3a064df
1 измененных файлов с 11 добавлено и 0 удалено
  1. 11 0
      Gruntfile.js

+ 11 - 0
Gruntfile.js

@@ -92,6 +92,16 @@ module.exports = function (grunt) {
                     mainConfigFile: "config.js",
                     rawText: {
                         "jquery": "/* do not load in node test runner */",
+                        "codemirror/lib/codemirror": "(" + function () {
+                            define(function () {
+                                function CodeMirror() {}
+                                CodeMirror.keyMap = {"default": {}};
+                                CodeMirror.commands = {};
+                                return CodeMirror;
+                            });
+                        } + "());",
+                        "codemirror/addon/hint/show-hint": "/* do not load in node test runner */",
+                        "codemirror/mode/smalltalk/smalltalk": "/* do not load in node test runner */",
                         "__app__": "(" + function () {
                             define(["amber/deploy", "helios/all", "amber/core/Platform-Node", "amber_devkit/NodeTestRunner"], function (amber) {
                                 amber.initialize().then(function () {
@@ -107,6 +117,7 @@ module.exports = function (grunt) {
                     },
                     include: ['app'],
                     findNestedDependencies: true,
+                    exclude: ['css!codemirror/lib/codemirror'],
                     insertRequire: ['app'],
                     optimize: "none",
                     wrap: helpers.nodeWrapperWithShebang,