@trickfilm400/rollup-plugin-off-main-thread 2.4.3 → 3.0.0-pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/.travis.yml +8 -8
  2. package/CONTRIBUTING +27 -27
  3. package/CONTRIBUTORS +11 -11
  4. package/LICENSE +202 -202
  5. package/README.md +97 -97
  6. package/index.js +318 -318
  7. package/karma.conf.js +46 -46
  8. package/loader.ejs +76 -76
  9. package/package.json +42 -42
  10. package/run_tests.js +105 -105
  11. package/tests/amd-function-name.test.js +33 -33
  12. package/tests/asset-in-worker.test.js +33 -33
  13. package/tests/dynamic-import.test.js +33 -33
  14. package/tests/fixtures/amd-function-name/a.js +16 -16
  15. package/tests/fixtures/amd-function-name/build/a-29701bae.js +22 -0
  16. package/tests/fixtures/amd-function-name/build/a-REsyh-LW.js +22 -0
  17. package/tests/fixtures/amd-function-name/build/a-bd62e735.js +22 -0
  18. package/tests/fixtures/amd-function-name/build/entry.js +95 -0
  19. package/tests/fixtures/amd-function-name/build/runner.html +15 -15
  20. package/tests/fixtures/amd-function-name/config.json +3 -3
  21. package/tests/fixtures/amd-function-name/entry.js +22 -22
  22. package/tests/fixtures/assets-in-worker/build/assets/my-asset-8db90352.bin +1 -0
  23. package/tests/fixtures/assets-in-worker/build/assets/my-asset-C4yNwep_.bin +1 -0
  24. package/tests/fixtures/assets-in-worker/build/entry.js +90 -0
  25. package/tests/fixtures/assets-in-worker/build/runner.html +15 -15
  26. package/tests/fixtures/assets-in-worker/build/worker-2a7f7c23.js +91 -0
  27. package/tests/fixtures/assets-in-worker/build/worker-5cc2068a.js +92 -0
  28. package/tests/fixtures/assets-in-worker/build/worker-CtBAebZB.js +92 -0
  29. package/tests/fixtures/assets-in-worker/entry.js +17 -17
  30. package/tests/fixtures/assets-in-worker/rollup.config.js +25 -25
  31. package/tests/fixtures/assets-in-worker/worker.js +18 -18
  32. package/tests/fixtures/dynamic-import/a.js +16 -16
  33. package/tests/fixtures/dynamic-import/build/a-Dqjf2iqw.js +22 -0
  34. package/tests/fixtures/dynamic-import/build/a-b9a1bf8d.js +22 -0
  35. package/tests/fixtures/dynamic-import/build/a-f1483003.js +22 -0
  36. package/tests/fixtures/dynamic-import/build/entry.js +87 -0
  37. package/tests/fixtures/dynamic-import/build/runner.html +15 -15
  38. package/tests/fixtures/dynamic-import/entry.js +14 -14
  39. package/tests/fixtures/import-meta/a.js +16 -16
  40. package/tests/fixtures/import-meta/build/a-115d949a.js +22 -0
  41. package/tests/fixtures/import-meta/build/a-550898d2.js +22 -0
  42. package/tests/fixtures/import-meta/build/a-BFYklafB.js +22 -0
  43. package/tests/fixtures/import-meta/build/entry.js +87 -0
  44. package/tests/fixtures/import-meta/build/runner.html +15 -15
  45. package/tests/fixtures/import-meta/entry.js +14 -14
  46. package/tests/fixtures/import-meta-worker/a.js +12 -12
  47. package/tests/fixtures/import-meta-worker/build/a-23c670a1.js +83 -0
  48. package/tests/fixtures/import-meta-worker/build/a-9c89b629.js +85 -0
  49. package/tests/fixtures/import-meta-worker/build/a-CrtsJ3Po.js +83 -0
  50. package/tests/fixtures/import-meta-worker/build/a-e0498c05.js +83 -0
  51. package/tests/fixtures/import-meta-worker/build/entry.js +94 -0
  52. package/tests/fixtures/import-meta-worker/build/runner.html +15 -15
  53. package/tests/fixtures/import-meta-worker/entry.js +22 -22
  54. package/tests/fixtures/import-worker-url/a.js +16 -16
  55. package/tests/fixtures/import-worker-url/b.js +16 -16
  56. package/tests/fixtures/import-worker-url/build/b-64a9d830.js +22 -0
  57. package/tests/fixtures/import-worker-url/build/b-725e92c1.js +5 -0
  58. package/tests/fixtures/import-worker-url/build/entry.js +95 -0
  59. package/tests/fixtures/import-worker-url/build/runner.html +15 -15
  60. package/tests/fixtures/import-worker-url/build/worker-Bq6uP7t8.js +123 -0
  61. package/tests/fixtures/import-worker-url/build/worker-ef1d7c89.js +106 -0
  62. package/tests/fixtures/import-worker-url/build/worker-f5690442.js +105 -0
  63. package/tests/fixtures/import-worker-url/entry.js +21 -21
  64. package/tests/fixtures/import-worker-url/worker.js +17 -17
  65. package/tests/fixtures/import-worker-url-custom-scheme/a.js +16 -16
  66. package/tests/fixtures/import-worker-url-custom-scheme/b.js +16 -16
  67. package/tests/fixtures/import-worker-url-custom-scheme/build/b-725e92c1.js +5 -0
  68. package/tests/fixtures/import-worker-url-custom-scheme/build/b-74a80c25.js +22 -0
  69. package/tests/fixtures/import-worker-url-custom-scheme/build/entry.js +95 -0
  70. package/tests/fixtures/import-worker-url-custom-scheme/build/runner.html +15 -15
  71. package/tests/fixtures/import-worker-url-custom-scheme/build/worker-Bq6uP7t8.js +123 -0
  72. package/tests/fixtures/import-worker-url-custom-scheme/build/worker-e37d535c.js +105 -0
  73. package/tests/fixtures/import-worker-url-custom-scheme/build/worker-ef1d7c89.js +106 -0
  74. package/tests/fixtures/import-worker-url-custom-scheme/config.json +3 -3
  75. package/tests/fixtures/import-worker-url-custom-scheme/entry.js +21 -21
  76. package/tests/fixtures/import-worker-url-custom-scheme/worker.js +17 -17
  77. package/tests/fixtures/module-worker/a.js +20 -20
  78. package/tests/fixtures/module-worker/b.js +20 -20
  79. package/tests/fixtures/module-worker/build/b-8d8ba280.js +20 -0
  80. package/tests/fixtures/module-worker/build/b-ZxqdL95j.js +21 -0
  81. package/tests/fixtures/module-worker/build/b-f6cfc895.js +21 -0
  82. package/tests/fixtures/module-worker/build/entry.js +17 -0
  83. package/tests/fixtures/module-worker/build/runner.html +15 -15
  84. package/tests/fixtures/module-worker/build/worker-41a1c649.js +1 -0
  85. package/tests/fixtures/module-worker/build/worker-50885fe8.js +38 -0
  86. package/tests/fixtures/module-worker/build/worker-9fb0618d.js +39 -0
  87. package/tests/fixtures/module-worker/build/worker-DWbjHYfx.js +39 -0
  88. package/tests/fixtures/module-worker/entry.js +17 -17
  89. package/tests/fixtures/module-worker/rollup.config.js +4 -4
  90. package/tests/fixtures/module-worker/worker.js +17 -17
  91. package/tests/fixtures/more-workers/a.js +16 -16
  92. package/tests/fixtures/more-workers/b.js +16 -16
  93. package/tests/fixtures/more-workers/build/b-Dok_VKGN.js +22 -0
  94. package/tests/fixtures/more-workers/build/b-e9bb9f94.js +22 -0
  95. package/tests/fixtures/more-workers/build/b-f31d0f9f.js +22 -0
  96. package/tests/fixtures/more-workers/build/entry.js +107 -0
  97. package/tests/fixtures/more-workers/build/runner.html +15 -15
  98. package/tests/fixtures/more-workers/build/worker_a-25924b0d.js +105 -0
  99. package/tests/fixtures/more-workers/build/worker_a-DtsyxKtN.js +105 -0
  100. package/tests/fixtures/more-workers/build/worker_a-b8e0ca8d.js +104 -0
  101. package/tests/fixtures/more-workers/build/worker_b-477edb2c.js +91 -0
  102. package/tests/fixtures/more-workers/build/worker_b-60981e1f.js +91 -0
  103. package/tests/fixtures/more-workers/build/worker_b-CG60Lcld.js +91 -0
  104. package/tests/fixtures/more-workers/entry.js +34 -34
  105. package/tests/fixtures/more-workers/worker_a.js +16 -16
  106. package/tests/fixtures/more-workers/worker_b.js +18 -18
  107. package/tests/fixtures/public-path/a.js +16 -16
  108. package/tests/fixtures/public-path/build/a-1fb502b9.js +22 -0
  109. package/tests/fixtures/public-path/build/a-Dqjf2iqw.js +22 -0
  110. package/tests/fixtures/public-path/build/a-b9a1bf8d.js +22 -0
  111. package/tests/fixtures/public-path/build/entry.js +87 -0
  112. package/tests/fixtures/public-path/build/runner.html +15 -15
  113. package/tests/fixtures/public-path/config.json +3 -3
  114. package/tests/fixtures/public-path/entry.js +14 -14
  115. package/tests/fixtures/simple-bundle/a.js +16 -16
  116. package/tests/fixtures/simple-bundle/build/entry.js +105 -0
  117. package/tests/fixtures/simple-bundle/build/runner.html +15 -15
  118. package/tests/fixtures/simple-bundle/entry.js +16 -16
  119. package/tests/fixtures/single-default/a.js +14 -14
  120. package/tests/fixtures/single-default/build/entry.js +103 -0
  121. package/tests/fixtures/single-default/build/runner.html +15 -15
  122. package/tests/fixtures/single-default/entry.js +16 -16
  123. package/tests/fixtures/url-import-meta-worker/a.js +17 -17
  124. package/tests/fixtures/url-import-meta-worker/b.js +16 -16
  125. package/tests/fixtures/url-import-meta-worker/build/b-258f8a6b.js +22 -0
  126. package/tests/fixtures/url-import-meta-worker/build/b-8c5ed926.js +22 -0
  127. package/tests/fixtures/url-import-meta-worker/build/b-CNJP1XvI.js +22 -0
  128. package/tests/fixtures/url-import-meta-worker/build/entry.js +91 -0
  129. package/tests/fixtures/url-import-meta-worker/build/runner.html +15 -15
  130. package/tests/fixtures/url-import-meta-worker/build/worker-9a661671.js +105 -0
  131. package/tests/fixtures/url-import-meta-worker/build/worker-S2Vh56Q-.js +106 -0
  132. package/tests/fixtures/url-import-meta-worker/build/worker-e833ae5d.js +106 -0
  133. package/tests/fixtures/url-import-meta-worker/entry.js +20 -20
  134. package/tests/fixtures/url-import-meta-worker/worker.js +16 -16
  135. package/tests/fixtures/worker/a.js +17 -17
  136. package/tests/fixtures/worker/b.js +16 -16
  137. package/tests/fixtures/worker/build/b-258f8a6b.js +22 -0
  138. package/tests/fixtures/worker/build/b-CNJP1XvI.js +22 -0
  139. package/tests/fixtures/worker/build/b-a9f43d76.js +22 -0
  140. package/tests/fixtures/worker/build/entry.js +91 -0
  141. package/tests/fixtures/worker/build/runner.html +15 -15
  142. package/tests/fixtures/worker/build/worker-S2Vh56Q-.js +106 -0
  143. package/tests/fixtures/worker/build/worker-b4897a54.js +105 -0
  144. package/tests/fixtures/worker/build/worker-e833ae5d.js +106 -0
  145. package/tests/fixtures/worker/entry.js +18 -18
  146. package/tests/fixtures/worker/worker.js +16 -16
  147. package/tests/import-meta-worker.test.js +37 -37
  148. package/tests/import-meta.test.js +33 -33
  149. package/tests/import-worker-url-custom-scheme.test.js +42 -42
  150. package/tests/import-worker-url.test.js +41 -41
  151. package/tests/module-worker.test.js +47 -47
  152. package/tests/more-workers.test.js +33 -33
  153. package/tests/public-path.test.js +33 -33
  154. package/tests/simple-bundle.test.js +33 -33
  155. package/tests/single-default.test.js +33 -33
  156. package/tests/url-import-meta-worker.test.js +34 -34
  157. package/tests/worker.test.js +33 -33
package/karma.conf.js CHANGED
@@ -1,46 +1,46 @@
1
- /**
2
- * Copyright 2018 Google Inc. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- * http://www.apache.org/licenses/LICENSE-2.0
7
- * Unless required by applicable law or agreed to in writing, software
8
- * distributed under the License is distributed on an "AS IS" BASIS,
9
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- * See the License for the specific language governing permissions and
11
- * limitations under the License.
12
- */
13
-
14
- module.exports = function(config) {
15
- const configuration = {
16
- basePath: "",
17
- frameworks: ["mocha", "chai"],
18
- files: [
19
- {
20
- pattern: "tests/fixtures/**",
21
- included: false
22
- },
23
- {
24
- pattern: "tests/*.test.js"
25
- }
26
- ],
27
- reporters: ["progress"],
28
- port: 9876,
29
- colors: true,
30
- logLevel: config.LOG_INFO,
31
- autoWatch: true,
32
- singleRun: true,
33
- concurrency: 1,
34
- browsers: ["Chrome", "Firefox", "Safari"],
35
- customLaunchers: {
36
- DockerChrome: {
37
- base: "ChromeHeadless",
38
- flags: ["--no-sandbox"]
39
- }
40
- }
41
- };
42
-
43
- if (process.env.INSIDE_DOCKER) configuration.browsers = ["DockerChrome"];
44
-
45
- config.set(configuration);
46
- };
1
+ /**
2
+ * Copyright 2018 Google Inc. All Rights Reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+
14
+ module.exports = function(config) {
15
+ const configuration = {
16
+ basePath: "",
17
+ frameworks: ["mocha", "chai"],
18
+ files: [
19
+ {
20
+ pattern: "tests/fixtures/**",
21
+ included: false
22
+ },
23
+ {
24
+ pattern: "tests/*.test.js"
25
+ }
26
+ ],
27
+ reporters: ["progress"],
28
+ port: 9876,
29
+ colors: true,
30
+ logLevel: config.LOG_INFO,
31
+ autoWatch: true,
32
+ singleRun: true,
33
+ concurrency: 1,
34
+ browsers: ["Chrome", "Firefox", "Safari"],
35
+ customLaunchers: {
36
+ DockerChrome: {
37
+ base: "ChromeHeadless",
38
+ flags: ["--no-sandbox"]
39
+ }
40
+ }
41
+ };
42
+
43
+ if (process.env.INSIDE_DOCKER) configuration.browsers = ["DockerChrome"];
44
+
45
+ config.set(configuration);
46
+ };
package/loader.ejs CHANGED
@@ -1,76 +1,76 @@
1
- /**
2
- * Copyright 2018 Google Inc. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- * http://www.apache.org/licenses/LICENSE-2.0
7
- * Unless required by applicable law or agreed to in writing, software
8
- * distributed under the License is distributed on an "AS IS" BASIS,
9
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- * See the License for the specific language governing permissions and
11
- * limitations under the License.
12
- */
13
-
14
- // If the loader is already loaded, just stop.
15
- if (!self.<%- amdFunctionName %>) {
16
- let registry = {};
17
-
18
- // Used for `eval` and `importScripts` where we can't get script URL by other means.
19
- // In both cases, it's safe to use a global var because those functions are synchronous.
20
- let nextDefineUri;
21
-
22
- const singleRequire = (uri, parentUri) => {
23
- uri = new URL(uri + ".js", parentUri).href;
24
- return registry[uri] || (
25
- <% if (useEval) { %>
26
- fetch(uri)
27
- .then(resp => resp.text())
28
- .then(code => {
29
- nextDefineUri = uri;
30
- eval(code);
31
- })
32
- <% } else { %>
33
- new Promise(resolve => {
34
- if ("document" in self) {
35
- const script = document.createElement("script");
36
- script.src = uri;
37
- script.onload = resolve;
38
- document.head.appendChild(script);
39
- } else {
40
- nextDefineUri = uri;
41
- importScripts(uri);
42
- resolve();
43
- }
44
- })
45
- <% } %>
46
- .then(() => {
47
- let promise = registry[uri];
48
- if (!promise) {
49
- throw new Error(`Module ${uri} didn’t register its module`);
50
- }
51
- return promise;
52
- })
53
- );
54
- };
55
-
56
- self.<%- amdFunctionName %> = (depsNames, factory) => {
57
- const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href;
58
- if (registry[uri]) {
59
- // Module is already loading or loaded.
60
- return;
61
- }
62
- let exports = {};
63
- const require = depUri => singleRequire(depUri, uri);
64
- const specialDeps = {
65
- module: { uri },
66
- exports,
67
- require
68
- };
69
- registry[uri] = Promise.all(depsNames.map(
70
- depName => specialDeps[depName] || require(depName)
71
- )).then(deps => {
72
- factory(...deps);
73
- return exports;
74
- });
75
- };
76
- }
1
+ /**
2
+ * Copyright 2018 Google Inc. All Rights Reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+
14
+ // If the loader is already loaded, just stop.
15
+ if (!self.<%- amdFunctionName %>) {
16
+ let registry = {};
17
+
18
+ // Used for `eval` and `importScripts` where we can't get script URL by other means.
19
+ // In both cases, it's safe to use a global var because those functions are synchronous.
20
+ let nextDefineUri;
21
+
22
+ const singleRequire = (uri, parentUri) => {
23
+ uri = new URL(uri + ".js", parentUri).href;
24
+ return registry[uri] || (
25
+ <% if (useEval) { %>
26
+ fetch(uri)
27
+ .then(resp => resp.text())
28
+ .then(code => {
29
+ nextDefineUri = uri;
30
+ eval(code);
31
+ })
32
+ <% } else { %>
33
+ new Promise(resolve => {
34
+ if ("document" in self) {
35
+ const script = document.createElement("script");
36
+ script.src = uri;
37
+ script.onload = resolve;
38
+ document.head.appendChild(script);
39
+ } else {
40
+ nextDefineUri = uri;
41
+ importScripts(uri);
42
+ resolve();
43
+ }
44
+ })
45
+ <% } %>
46
+ .then(() => {
47
+ let promise = registry[uri];
48
+ if (!promise) {
49
+ throw new Error(`Module ${uri} didn’t register its module`);
50
+ }
51
+ return promise;
52
+ })
53
+ );
54
+ };
55
+
56
+ self.<%- amdFunctionName %> = (depsNames, factory) => {
57
+ const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href;
58
+ if (registry[uri]) {
59
+ // Module is already loading or loaded.
60
+ return;
61
+ }
62
+ let exports = {};
63
+ const require = depUri => singleRequire(depUri, uri);
64
+ const specialDeps = {
65
+ module: { uri },
66
+ exports,
67
+ require
68
+ };
69
+ registry[uri] = Promise.all(depsNames.map(
70
+ depName => specialDeps[depName] || require(depName)
71
+ )).then(deps => {
72
+ factory(...deps);
73
+ return exports;
74
+ });
75
+ };
76
+ }
package/package.json CHANGED
@@ -1,42 +1,42 @@
1
- {
2
- "name": "@trickfilm400/rollup-plugin-off-main-thread",
3
- "version": "2.4.3",
4
- "description": "Use Rollup with workers and ES6 modules today.",
5
- "main": "index.js",
6
- "scripts": {
7
- "fmt": "prettier --write 'tests/**/*.js' *.js *.md *.json",
8
- "test": "node ./run_tests.js"
9
- },
10
- "author": "Surma <surma@google.com>",
11
- "contributors": [
12
- "trickfilm400 <trickfilm400@gmail.com>"
13
- ],
14
- "license": "Apache-2.0",
15
- "devDependencies": {
16
- "chai": "4.2.0",
17
- "chalk": "^2.4.2",
18
- "karma": "4.2.0",
19
- "karma-chai": "0.1.0",
20
- "karma-chrome-launcher": "3.0.0",
21
- "karma-firefox-launcher": "1.1.0",
22
- "karma-mocha": "1.3.0",
23
- "karma-safari-launcher": "1.0.0",
24
- "karma-safaritechpreview-launcher": "2.0.2",
25
- "mocha": "6.1.4",
26
- "prettier": "1.18.2",
27
- "rollup": "2.2.0"
28
- },
29
- "repository": {
30
- "type": "git",
31
- "url": "https://github.com/Trickfilm400/rollup-plugin-off-main-thread"
32
- },
33
- "dependencies": {
34
- "ejs": "^3.1.10",
35
- "json5": "^2.2.3",
36
- "magic-string": "^0.30.10",
37
- "string.prototype.matchall": "^4.0.11"
38
- },
39
- "engines": {
40
- "node": ">=12"
41
- }
42
- }
1
+ {
2
+ "name": "@trickfilm400/rollup-plugin-off-main-thread",
3
+ "version": "3.0.0-pre1",
4
+ "description": "Use Rollup with workers and ES6 modules today.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "fmt": "prettier --write 'tests/**/*.js' *.js *.md *.json",
8
+ "test": "node ./run_tests.js"
9
+ },
10
+ "author": "Surma <surma@google.com>",
11
+ "contributors": [
12
+ "trickfilm400 <trickfilm400@gmail.com>"
13
+ ],
14
+ "license": "Apache-2.0",
15
+ "devDependencies": {
16
+ "chai": "4.5.0",
17
+ "chalk": "^4.1.2",
18
+ "karma": "^6.4.4",
19
+ "karma-chai": "0.1.0",
20
+ "karma-chrome-launcher": "3.2.0",
21
+ "karma-firefox-launcher": "^2.1.3",
22
+ "karma-mocha": "^2.0.1",
23
+ "karma-safari-launcher": "1.0.0",
24
+ "karma-safaritechpreview-launcher": "2.0.2",
25
+ "mocha": "^11.7.5",
26
+ "prettier": "^3.7.3",
27
+ "rollup": "^4.53.3"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/Trickfilm400/rollup-plugin-off-main-thread"
32
+ },
33
+ "dependencies": {
34
+ "ejs": "^3.1.10",
35
+ "json5": "^2.2.3",
36
+ "magic-string": "^0.30.21",
37
+ "string.prototype.matchall": "^4.0.12"
38
+ },
39
+ "engines": {
40
+ "node": ">=12"
41
+ }
42
+ }
package/run_tests.js CHANGED
@@ -1,105 +1,105 @@
1
- /**
2
- * Copyright 2018 Google Inc. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- * http://www.apache.org/licenses/LICENSE-2.0
7
- * Unless required by applicable law or agreed to in writing, software
8
- * distributed under the License is distributed on an "AS IS" BASIS,
9
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- * See the License for the specific language governing permissions and
11
- * limitations under the License.
12
- */
13
-
14
- const rollup = require("rollup");
15
- const path = require("path");
16
- const omt = require(".");
17
- const fs = require("fs");
18
- const chalk = require("chalk");
19
-
20
- const karma = require("karma");
21
- const myKarmaConfig = require("./karma.conf.js");
22
-
23
- async function fileExists(file) {
24
- try {
25
- const stat = await fs.promises.stat(file);
26
- return stat.isFile();
27
- } catch (e) {
28
- return false;
29
- }
30
- }
31
-
32
- async function init() {
33
- await Promise.all(
34
- [
35
- "./tests/fixtures/simple-bundle/entry.js",
36
- "./tests/fixtures/import-meta/entry.js",
37
- "./tests/fixtures/dynamic-import/entry.js",
38
- "./tests/fixtures/public-path/entry.js",
39
- "./tests/fixtures/worker/entry.js",
40
- "./tests/fixtures/module-worker/entry.js",
41
- "./tests/fixtures/more-workers/entry.js",
42
- "./tests/fixtures/amd-function-name/entry.js",
43
- "./tests/fixtures/single-default/entry.js",
44
- "./tests/fixtures/import-worker-url/entry.js",
45
- "./tests/fixtures/import-meta-worker/entry.js",
46
- "./tests/fixtures/import-worker-url-custom-scheme/entry.js",
47
- "./tests/fixtures/assets-in-worker/entry.js",
48
- "./tests/fixtures/url-import-meta-worker/entry.js"
49
- ].map(async input => {
50
- const pathName = path.dirname(input);
51
- const outputOptions = {
52
- dir: path.join(pathName, "build"),
53
- format: "amd"
54
- };
55
- let rollupConfig = {
56
- input,
57
- strictDeprecations: true,
58
- // Copied / adapted from default `onwarn` in Rollup CLI.
59
- onwarn: warning => {
60
- console.warn(`⚠️ ${chalk.bold(warning.message)}`);
61
-
62
- if (warning.url) {
63
- console.warn(chalk.cyan(warning.url));
64
- }
65
-
66
- if (warning.loc) {
67
- console.warn(
68
- `${warning.loc.file} (${warning.loc.line}:${warning.loc.column})`
69
- );
70
- }
71
-
72
- if (warning.frame) {
73
- console.warn(chalk.dim(warning.frame));
74
- }
75
-
76
- console.warn("");
77
- }
78
- };
79
- const rollupConfigPath = "./" + path.join(pathName, "rollup.config.js");
80
- const configPath = "./" + path.join(pathName, "config.json");
81
- if (await fileExists(rollupConfigPath)) {
82
- require(rollupConfigPath)(rollupConfig, outputOptions, omt);
83
- } else if (await fileExists(configPath)) {
84
- rollupConfig.plugins = [omt(require(configPath))];
85
- } else {
86
- rollupConfig.plugins = [omt()];
87
- }
88
- const bundle = await rollup.rollup(rollupConfig);
89
- await bundle.write(outputOptions);
90
- })
91
- );
92
-
93
- const karmaConfig = { port: 9876 };
94
- myKarmaConfig({
95
- set(config) {
96
- Object.assign(karmaConfig, config);
97
- }
98
- });
99
- const server = new karma.Server(karmaConfig, code => {
100
- console.log(`Karma exited with code ${code}`);
101
- process.exit(code);
102
- });
103
- server.start();
104
- }
105
- init();
1
+ /**
2
+ * Copyright 2018 Google Inc. All Rights Reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+
14
+ const rollup = require("rollup");
15
+ const path = require("path");
16
+ const omt = require(".");
17
+ const fs = require("fs");
18
+ const chalk = require("chalk");
19
+
20
+ const karma = require("karma");
21
+ const myKarmaConfig = require("./karma.conf.js");
22
+
23
+ async function fileExists(file) {
24
+ try {
25
+ const stat = await fs.promises.stat(file);
26
+ return stat.isFile();
27
+ } catch (e) {
28
+ return false;
29
+ }
30
+ }
31
+
32
+ async function init() {
33
+ await Promise.all(
34
+ [
35
+ "./tests/fixtures/simple-bundle/entry.js",
36
+ "./tests/fixtures/import-meta/entry.js",
37
+ "./tests/fixtures/dynamic-import/entry.js",
38
+ "./tests/fixtures/public-path/entry.js",
39
+ "./tests/fixtures/worker/entry.js",
40
+ "./tests/fixtures/module-worker/entry.js",
41
+ "./tests/fixtures/more-workers/entry.js",
42
+ "./tests/fixtures/amd-function-name/entry.js",
43
+ "./tests/fixtures/single-default/entry.js",
44
+ "./tests/fixtures/import-worker-url/entry.js",
45
+ "./tests/fixtures/import-meta-worker/entry.js",
46
+ "./tests/fixtures/import-worker-url-custom-scheme/entry.js",
47
+ "./tests/fixtures/assets-in-worker/entry.js",
48
+ "./tests/fixtures/url-import-meta-worker/entry.js"
49
+ ].map(async input => {
50
+ const pathName = path.dirname(input);
51
+ const outputOptions = {
52
+ dir: path.join(pathName, "build"),
53
+ format: "amd"
54
+ };
55
+ let rollupConfig = {
56
+ input,
57
+ strictDeprecations: true,
58
+ // Copied / adapted from default `onwarn` in Rollup CLI.
59
+ onwarn: warning => {
60
+ console.warn(`⚠️ ${chalk.bold(warning.message)}`);
61
+
62
+ if (warning.url) {
63
+ console.warn(chalk.cyan(warning.url));
64
+ }
65
+
66
+ if (warning.loc) {
67
+ console.warn(
68
+ `${warning.loc.file} (${warning.loc.line}:${warning.loc.column})`
69
+ );
70
+ }
71
+
72
+ if (warning.frame) {
73
+ console.warn(chalk.dim(warning.frame));
74
+ }
75
+
76
+ console.warn("");
77
+ }
78
+ };
79
+ const rollupConfigPath = "./" + path.join(pathName, "rollup.config.js");
80
+ const configPath = "./" + path.join(pathName, "config.json");
81
+ if (await fileExists(rollupConfigPath)) {
82
+ require(rollupConfigPath)(rollupConfig, outputOptions, omt);
83
+ } else if (await fileExists(configPath)) {
84
+ rollupConfig.plugins = [omt(require(configPath))];
85
+ } else {
86
+ rollupConfig.plugins = [omt()];
87
+ }
88
+ const bundle = await rollup.rollup(rollupConfig);
89
+ await bundle.write(outputOptions);
90
+ })
91
+ );
92
+
93
+ const karmaConfig = { port: 9876 };
94
+ myKarmaConfig({
95
+ set(config) {
96
+ Object.assign(karmaConfig, config);
97
+ }
98
+ });
99
+ const server = new karma.Server(karmaConfig, code => {
100
+ console.log(`Karma exited with code ${code}`);
101
+ process.exit(code);
102
+ });
103
+ server.start();
104
+ }
105
+ init();
@@ -1,33 +1,33 @@
1
- /**
2
- * Copyright 2018 Google Inc. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- * http://www.apache.org/licenses/LICENSE-2.0
7
- * Unless required by applicable law or agreed to in writing, software
8
- * distributed under the License is distributed on an "AS IS" BASIS,
9
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- * See the License for the specific language governing permissions and
11
- * limitations under the License.
12
- */
13
-
14
- describe("AMD Function Name", function() {
15
- beforeEach(function() {
16
- this.ifr = document.createElement("iframe");
17
- document.body.append(this.ifr);
18
- });
19
-
20
- afterEach(function() {
21
- this.ifr.remove();
22
- });
23
-
24
- it("loads with a different AMD function name", function(done) {
25
- window.addEventListener("message", function l(ev) {
26
- if (ev.data === "a") {
27
- window.removeEventListener("message", l);
28
- done();
29
- }
30
- });
31
- this.ifr.src = "/base/tests/fixtures/amd-function-name/build/runner.html";
32
- });
33
- });
1
+ /**
2
+ * Copyright 2018 Google Inc. All Rights Reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+
14
+ describe("AMD Function Name", function() {
15
+ beforeEach(function() {
16
+ this.ifr = document.createElement("iframe");
17
+ document.body.append(this.ifr);
18
+ });
19
+
20
+ afterEach(function() {
21
+ this.ifr.remove();
22
+ });
23
+
24
+ it("loads with a different AMD function name", function(done) {
25
+ window.addEventListener("message", function l(ev) {
26
+ if (ev.data === "a") {
27
+ window.removeEventListener("message", l);
28
+ done();
29
+ }
30
+ });
31
+ this.ifr.src = "/base/tests/fixtures/amd-function-name/build/runner.html";
32
+ });
33
+ });