@cocojs/bundle-rollup 0.0.1-alpha.7 → 0.0.1-beta.9

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) jiangchenguang.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var rollup = require('rollup');
6
4
  var babel = require('@rollup/plugin-babel');
7
5
  var compiler = require('@cocojs/compiler');
@@ -39,6 +37,54 @@ function _asyncToGenerator(n) {
39
37
  });
40
38
  };
41
39
  }
40
+ function _createForOfIteratorHelper(r, e) {
41
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
42
+ if (!t) {
43
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
44
+ t && (r = t);
45
+ var n = 0,
46
+ F = function () {};
47
+ return {
48
+ s: F,
49
+ n: function () {
50
+ return n >= r.length ? {
51
+ done: true
52
+ } : {
53
+ done: false,
54
+ value: r[n++]
55
+ };
56
+ },
57
+ e: function (r) {
58
+ throw r;
59
+ },
60
+ f: F
61
+ };
62
+ }
63
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
64
+ }
65
+ var o,
66
+ a = true,
67
+ u = false;
68
+ return {
69
+ s: function () {
70
+ t = t.call(r);
71
+ },
72
+ n: function () {
73
+ var r = t.next();
74
+ return a = r.done, r;
75
+ },
76
+ e: function (r) {
77
+ u = true, o = r;
78
+ },
79
+ f: function () {
80
+ try {
81
+ a || null == t.return || t.return();
82
+ } finally {
83
+ if (u) throw o;
84
+ }
85
+ }
86
+ };
87
+ }
42
88
  function _iterableToArray(r) {
43
89
  if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
44
90
  }
@@ -188,9 +234,9 @@ function customBuild() {
188
234
  }
189
235
  function _build() {
190
236
  _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(rollupOption, pluginOption) {
191
- var input, output, plugins, rollupBuild, rollupOutput, _t;
237
+ var input, output, plugins, rollupBuild, outputIsArray, outputList, rollupOutput, _iterator, _step, out, result, _t, _t2;
192
238
  return _regenerator().w(function (_context) {
193
- while (1) switch (_context.n) {
239
+ while (1) switch (_context.p = _context.n) {
194
240
  case 0:
195
241
  input = rollupOption.input, output = rollupOption.output, plugins = rollupOption.plugins;
196
242
  _context.n = 1;
@@ -208,29 +254,57 @@ function customBuild() {
208
254
  });
209
255
  case 1:
210
256
  rollupBuild = _context.v;
257
+ outputIsArray = Array.isArray(output);
258
+ outputList = outputIsArray ? output : [output];
259
+ rollupOutput = [];
260
+ _iterator = _createForOfIteratorHelper(outputList);
261
+ _context.p = 2;
262
+ _iterator.s();
263
+ case 3:
264
+ if ((_step = _iterator.n()).done) {
265
+ _context.n = 9;
266
+ break;
267
+ }
268
+ out = _step.value;
211
269
  if (!useGenerate) {
212
- _context.n = 3;
270
+ _context.n = 5;
213
271
  break;
214
272
  }
215
- _context.n = 2;
216
- return rollupBuild.generate(output);
217
- case 2:
218
- _t = _context.v;
219
- _context.n = 5;
220
- break;
221
- case 3:
222
273
  _context.n = 4;
223
- return rollupBuild.write(output);
274
+ return rollupBuild.generate(out);
224
275
  case 4:
225
276
  _t = _context.v;
277
+ _context.n = 7;
278
+ break;
226
279
  case 5:
227
- rollupOutput = _t;
280
+ _context.n = 6;
281
+ return rollupBuild.write(out);
282
+ case 6:
283
+ _t = _context.v;
284
+ case 7:
285
+ result = _t;
286
+ rollupOutput.push(result);
287
+ case 8:
288
+ _context.n = 3;
289
+ break;
290
+ case 9:
291
+ _context.n = 11;
292
+ break;
293
+ case 10:
294
+ _context.p = 10;
295
+ _t2 = _context.v;
296
+ _iterator.e(_t2);
297
+ case 11:
298
+ _context.p = 11;
299
+ _iterator.f();
300
+ return _context.f(11);
301
+ case 12:
228
302
  return _context.a(2, {
229
303
  rollupBuild: rollupBuild,
230
- rollupOutput: rollupOutput
304
+ rollupOutput: outputIsArray ? rollupOutput : rollupOutput[0]
231
305
  });
232
306
  }
233
- }, _callee);
307
+ }, _callee, null, [[2, 10, 11, 12]]);
234
308
  }));
235
309
  return _build.apply(this, arguments);
236
310
  }
@@ -238,5 +312,5 @@ function customBuild() {
238
312
  }
239
313
  var bundle = customBuild();
240
314
 
315
+ exports.bundle = bundle;
241
316
  exports.customBuild = customBuild;
242
- exports.default = bundle;
package/dist/index.d.ts CHANGED
@@ -2,15 +2,14 @@ import { RollupBuild } from 'rollup';
2
2
  import { RollupOptions } from 'rollup';
3
3
  import { RollupOutput } from 'rollup';
4
4
 
5
- declare const bundle: (rollupOption: RollupOptions, pluginOption: PluginOption) => Promise<{
5
+ export declare const bundle: (rollupOption: RollupOptions, pluginOption: PluginOption) => Promise<{
6
6
  rollupBuild: RollupBuild;
7
- rollupOutput: RollupOutput;
7
+ rollupOutput: RollupOutput | RollupOutput[];
8
8
  }>;
9
- export default bundle;
10
9
 
11
10
  export declare function customBuild(option?: IOption): (rollupOption: RollupOptions, pluginOption: PluginOption) => Promise<{
12
11
  rollupBuild: RollupBuild;
13
- rollupOutput: RollupOutput;
12
+ rollupOutput: RollupOutput | RollupOutput[];
14
13
  }>;
15
14
 
16
15
  declare interface IOption {
@@ -0,0 +1,313 @@
1
+ import { rollup } from 'rollup';
2
+ import babel from '@rollup/plugin-babel';
3
+ import { compileOneFile } from '@cocojs/compiler';
4
+
5
+ function _arrayLikeToArray(r, a) {
6
+ (null == a || a > r.length) && (a = r.length);
7
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
8
+ return n;
9
+ }
10
+ function _arrayWithoutHoles(r) {
11
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
12
+ }
13
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
14
+ try {
15
+ var i = n[a](c),
16
+ u = i.value;
17
+ } catch (n) {
18
+ return void e(n);
19
+ }
20
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
21
+ }
22
+ function _asyncToGenerator(n) {
23
+ return function () {
24
+ var t = this,
25
+ e = arguments;
26
+ return new Promise(function (r, o) {
27
+ var a = n.apply(t, e);
28
+ function _next(n) {
29
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
30
+ }
31
+ function _throw(n) {
32
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
33
+ }
34
+ _next(void 0);
35
+ });
36
+ };
37
+ }
38
+ function _createForOfIteratorHelper(r, e) {
39
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
40
+ if (!t) {
41
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
42
+ t && (r = t);
43
+ var n = 0,
44
+ F = function () {};
45
+ return {
46
+ s: F,
47
+ n: function () {
48
+ return n >= r.length ? {
49
+ done: true
50
+ } : {
51
+ done: false,
52
+ value: r[n++]
53
+ };
54
+ },
55
+ e: function (r) {
56
+ throw r;
57
+ },
58
+ f: F
59
+ };
60
+ }
61
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
62
+ }
63
+ var o,
64
+ a = true,
65
+ u = false;
66
+ return {
67
+ s: function () {
68
+ t = t.call(r);
69
+ },
70
+ n: function () {
71
+ var r = t.next();
72
+ return a = r.done, r;
73
+ },
74
+ e: function (r) {
75
+ u = true, o = r;
76
+ },
77
+ f: function () {
78
+ try {
79
+ a || null == t.return || t.return();
80
+ } finally {
81
+ if (u) throw o;
82
+ }
83
+ }
84
+ };
85
+ }
86
+ function _iterableToArray(r) {
87
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
88
+ }
89
+ function _nonIterableSpread() {
90
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
91
+ }
92
+ function _regenerator() {
93
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
94
+ var e,
95
+ t,
96
+ r = "function" == typeof Symbol ? Symbol : {},
97
+ n = r.iterator || "@@iterator",
98
+ o = r.toStringTag || "@@toStringTag";
99
+ function i(r, n, o, i) {
100
+ var c = n && n.prototype instanceof Generator ? n : Generator,
101
+ u = Object.create(c.prototype);
102
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
103
+ var i,
104
+ c,
105
+ u,
106
+ f = 0,
107
+ p = o || [],
108
+ y = false,
109
+ G = {
110
+ p: 0,
111
+ n: 0,
112
+ v: e,
113
+ a: d,
114
+ f: d.bind(e, 4),
115
+ d: function (t, r) {
116
+ return i = t, c = 0, u = e, G.n = r, a;
117
+ }
118
+ };
119
+ function d(r, n) {
120
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
121
+ var o,
122
+ i = p[t],
123
+ d = G.p,
124
+ l = i[2];
125
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
126
+ }
127
+ if (o || r > 1) return a;
128
+ throw y = true, n;
129
+ }
130
+ return function (o, p, l) {
131
+ if (f > 1) throw TypeError("Generator is already running");
132
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
133
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
134
+ try {
135
+ if (f = 2, i) {
136
+ if (c || (o = "next"), t = i[o]) {
137
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
138
+ if (!t.done) return t;
139
+ u = t.value, c < 2 && (c = 0);
140
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
141
+ i = e;
142
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
143
+ } catch (t) {
144
+ i = e, c = 1, u = t;
145
+ } finally {
146
+ f = 1;
147
+ }
148
+ }
149
+ return {
150
+ value: t,
151
+ done: y
152
+ };
153
+ };
154
+ }(r, o, i), true), u;
155
+ }
156
+ var a = {};
157
+ function Generator() {}
158
+ function GeneratorFunction() {}
159
+ function GeneratorFunctionPrototype() {}
160
+ t = Object.getPrototypeOf;
161
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
162
+ return this;
163
+ }), t),
164
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
165
+ function f(e) {
166
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
167
+ }
168
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
169
+ return this;
170
+ }), _regeneratorDefine(u, "toString", function () {
171
+ return "[object Generator]";
172
+ }), (_regenerator = function () {
173
+ return {
174
+ w: i,
175
+ m: f
176
+ };
177
+ })();
178
+ }
179
+ function _regeneratorDefine(e, r, n, t) {
180
+ var i = Object.defineProperty;
181
+ try {
182
+ i({}, "", {});
183
+ } catch (e) {
184
+ i = 0;
185
+ }
186
+ _regeneratorDefine = function (e, r, n, t) {
187
+ function o(r, n) {
188
+ _regeneratorDefine(e, r, function (e) {
189
+ return this._invoke(r, n, e);
190
+ });
191
+ }
192
+ r ? i ? i(e, r, {
193
+ value: n,
194
+ enumerable: !t,
195
+ configurable: !t,
196
+ writable: !t
197
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
198
+ }, _regeneratorDefine(e, r, n, t);
199
+ }
200
+ function _toConsumableArray(r) {
201
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
202
+ }
203
+ function _unsupportedIterableToArray(r, a) {
204
+ if (r) {
205
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
206
+ var t = {}.toString.call(r).slice(8, -1);
207
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
208
+ }
209
+ }
210
+
211
+ function cocoMvcPlugin() {
212
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
213
+ idPrefix = _ref.idPrefix;
214
+ return {
215
+ name: 'rollup-plugin-coco-mvc',
216
+ transform: function transform(code, id) {
217
+ try {
218
+ var output = compileOneFile(code, id, idPrefix);
219
+ return output;
220
+ } catch (e) {
221
+ this.error(e.message);
222
+ }
223
+ }
224
+ };
225
+ }
226
+
227
+ function customBuild() {
228
+ var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
229
+ var useGenerate = option.useGenerate;
230
+ function build(_x, _x2) {
231
+ return _build.apply(this, arguments);
232
+ }
233
+ function _build() {
234
+ _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(rollupOption, pluginOption) {
235
+ var input, output, plugins, rollupBuild, outputIsArray, outputList, rollupOutput, _iterator, _step, out, result, _t, _t2;
236
+ return _regenerator().w(function (_context) {
237
+ while (1) switch (_context.p = _context.n) {
238
+ case 0:
239
+ input = rollupOption.input, output = rollupOption.output, plugins = rollupOption.plugins;
240
+ _context.n = 1;
241
+ return rollup({
242
+ input: input,
243
+ plugins: [].concat(_toConsumableArray(Array.isArray(plugins) ? plugins : []), [cocoMvcPlugin(pluginOption), babel({
244
+ extensions: ['.ts', '.tsx'],
245
+ plugins: [[require.resolve('@babel/plugin-proposal-decorators'), {
246
+ version: '2023-11'
247
+ }], [require.resolve('@babel/plugin-transform-react-jsx'), {
248
+ runtime: 'automatic',
249
+ importSource: '@cocojs/mvc'
250
+ }]]
251
+ })])
252
+ });
253
+ case 1:
254
+ rollupBuild = _context.v;
255
+ outputIsArray = Array.isArray(output);
256
+ outputList = outputIsArray ? output : [output];
257
+ rollupOutput = [];
258
+ _iterator = _createForOfIteratorHelper(outputList);
259
+ _context.p = 2;
260
+ _iterator.s();
261
+ case 3:
262
+ if ((_step = _iterator.n()).done) {
263
+ _context.n = 9;
264
+ break;
265
+ }
266
+ out = _step.value;
267
+ if (!useGenerate) {
268
+ _context.n = 5;
269
+ break;
270
+ }
271
+ _context.n = 4;
272
+ return rollupBuild.generate(out);
273
+ case 4:
274
+ _t = _context.v;
275
+ _context.n = 7;
276
+ break;
277
+ case 5:
278
+ _context.n = 6;
279
+ return rollupBuild.write(out);
280
+ case 6:
281
+ _t = _context.v;
282
+ case 7:
283
+ result = _t;
284
+ rollupOutput.push(result);
285
+ case 8:
286
+ _context.n = 3;
287
+ break;
288
+ case 9:
289
+ _context.n = 11;
290
+ break;
291
+ case 10:
292
+ _context.p = 10;
293
+ _t2 = _context.v;
294
+ _iterator.e(_t2);
295
+ case 11:
296
+ _context.p = 11;
297
+ _iterator.f();
298
+ return _context.f(11);
299
+ case 12:
300
+ return _context.a(2, {
301
+ rollupBuild: rollupBuild,
302
+ rollupOutput: outputIsArray ? rollupOutput : rollupOutput[0]
303
+ });
304
+ }
305
+ }, _callee, null, [[2, 10, 11, 12]]);
306
+ }));
307
+ return _build.apply(this, arguments);
308
+ }
309
+ return build;
310
+ }
311
+ var bundle = customBuild();
312
+
313
+ export { bundle, customBuild };
package/package.json CHANGED
@@ -1,40 +1,41 @@
1
1
  {
2
- "name": "@cocojs/bundle-rollup",
3
- "version": "0.0.1-alpha.7",
4
- "description": "A rollup bundler for coco-mvc.",
5
- "main": "dist/index.cjs.js",
6
- "types": "dist/index.d.ts",
7
- "files": [
8
- "dist"
9
- ],
10
- "publishConfig": {
11
- "registry": "https://registry.npmjs.org/",
12
- "access": "public"
13
- },
14
- "keywords": [],
15
- "bugs": {
16
- "url": "https://github.com/cocojs-org/coconut-framework/issues"
17
- },
18
- "homepage": "https://github.com/cocojs-org/coconut-framework",
19
- "repository": {
20
- "type": "git",
21
- "url": "https://github.com/cocojs-org/coconut-framework.git"
22
- },
23
- "scripts": {
24
- "jest": "jest"
25
- },
26
- "devDependencies": {
27
- "@types/jest": "^29.5.14",
28
- "@types/node": "^20.0.0",
29
- "jest": "^29.7.0"
30
- },
31
- "license": "MIT",
32
- "author": "",
33
- "dependencies": {
34
- "@babel/plugin-proposal-decorators": "^7.28.0",
35
- "@babel/plugin-transform-react-jsx": "^7.27.1",
36
- "@cocojs/compiler": "workspace:*",
37
- "@rollup/plugin-babel": "^6.1.0",
38
- "rollup": "^4.53.3"
39
- }
40
- }
2
+ "name": "@cocojs/bundle-rollup",
3
+ "version": "0.0.1-beta.9",
4
+ "description": "A rollup bundler for coco-mvc.",
5
+ "main": "dist/index.cjs.js",
6
+ "module": "dist/index.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "publishConfig": {
12
+ "registry": "https://registry.npmjs.org/",
13
+ "access": "public"
14
+ },
15
+ "keywords": [],
16
+ "bugs": {
17
+ "url": "https://github.com/cocojs-org/coconut-framework/issues"
18
+ },
19
+ "homepage": "https://github.com/cocojs-org/coconut-framework",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/cocojs-org/coconut-framework.git"
23
+ },
24
+ "devDependencies": {
25
+ "@types/jest": "^29.5.14",
26
+ "@types/node": "^20.0.0",
27
+ "jest": "^29.7.0"
28
+ },
29
+ "license": "MIT",
30
+ "author": "",
31
+ "dependencies": {
32
+ "@babel/plugin-proposal-decorators": "^7.28.0",
33
+ "@babel/plugin-transform-react-jsx": "^7.27.1",
34
+ "@rollup/plugin-babel": "^6.1.0",
35
+ "rollup": "^4.53.3",
36
+ "@cocojs/compiler": "0.1.0-beta.202601082202"
37
+ },
38
+ "scripts": {
39
+ "jest": "jest"
40
+ }
41
+ }