From 137a64e6305bdd4a67170aef58f277892c8e853a Mon Sep 17 00:00:00 2001 From: Manuel Mujica Date: Wed, 27 Sep 2017 12:30:13 -0600 Subject: [PATCH] Support AMD "module" import in slim builds Closes #845 --- package.json | 4 ++-- test/slim/module/index.html | 10 ++++++++++ test/slim/module/main.js | 3 +++ test/slim/module/stealconfig.js | 3 +++ test/slim_build_test.js | 23 +++++++++++++++++++++++ 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 test/slim/module/index.html create mode 100644 test/slim/module/main.js create mode 100644 test/slim/module/stealconfig.js diff --git a/package.json b/package.json index 3cfba114..d19c5e86 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "through2": "^2.0.0", "tmp": "0.0.33", "traceur": "0.0.111", - "transpile": "^2.5.3", + "transpile": "^2.5.5", "uglify-es": "^3.0.26", "urix": "^0.1.0", "winston": "^2.2.0", @@ -88,7 +88,7 @@ "coverage": "istanbul cover _mocha -- test/test --timeout 600000", "coverage:upload": "istanbul cover _mocha --report lcovonly -- test/test --timeout 600000 && cat ./coverage/lcov.info | ./node_modules/coveralls-send/bin/coveralls.js", "test:slim-worker-single": "node test/slim/worker/single/build.js && testee test/slim/worker/single/worker.html --browsers firefox --reporter Spec", - "test:slim-worker-progressive": "node test/slim/worker/progressive/build.js && testee test/slim/worker/progressive/worker.html --browsers firefox --reporter Spec", + "test:slim-worker-progressive": "node test/slim/worker/progressive/build.js && testee test/slim/worker/progressive/worker.html --browsers firefox --reporter Spec", "test:exports-worker": "node test/exports_worker/exports.js && testee test/exports_worker/worker.html --browsers firefox --reporter Spec" }, "engines": { diff --git a/test/slim/module/index.html b/test/slim/module/index.html new file mode 100644 index 00000000..6ffe1550 --- /dev/null +++ b/test/slim/module/index.html @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/test/slim/module/main.js b/test/slim/module/main.js new file mode 100644 index 00000000..92c6f9a7 --- /dev/null +++ b/test/slim/module/main.js @@ -0,0 +1,3 @@ +define(["module"], function(module) { + window.moduleId = module.id; +}); diff --git a/test/slim/module/stealconfig.js b/test/slim/module/stealconfig.js new file mode 100644 index 00000000..5f703aa0 --- /dev/null +++ b/test/slim/module/stealconfig.js @@ -0,0 +1,3 @@ +steal.config({ + main: "main" +}); diff --git a/test/slim_build_test.js b/test/slim_build_test.js index d9bb505b..e28dcbbc 100644 --- a/test/slim_build_test.js +++ b/test/slim_build_test.js @@ -675,4 +675,27 @@ describe("slim builds", function() { close(); }); }); + + it("supports 'module' imports in AMD modules", function() { + var base = path.join(__dirname, "slim", "module"); + var config = { config: path.join(base, "stealconfig.js") }; + + return rmdir(path.join(base, "dist")) + .then(function() { + return optimize(config, { minify: false, quiet: true }); + }) + .then(function() { + return open(path.join("test", "slim", "module", "index.html")); + }) + .then(function(args) { + return Promise.all([args.close, find(args.browser, "moduleId")]); + }) + .then(function(data) { + var close = data[0]; + var moduleId = data[1]; + + assert.equal(moduleId, "main", "should set module.id"); + close(); + }); + }); });