@cocojs/bundle-rollup 0.0.1-alpha.7 → 0.0.1-beta.11
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 +21 -0
- package/dist/index.cjs.js +103 -19
- package/dist/index.d.ts +3 -4
- package/dist/index.esm.js +323 -0
- package/package.json +41 -39
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,8 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var rollup = require('rollup');
|
|
4
|
+
var resolve = require('@rollup/plugin-node-resolve');
|
|
6
5
|
var babel = require('@rollup/plugin-babel');
|
|
7
6
|
var compiler = require('@cocojs/compiler');
|
|
8
7
|
|
|
@@ -39,6 +38,54 @@ function _asyncToGenerator(n) {
|
|
|
39
38
|
});
|
|
40
39
|
};
|
|
41
40
|
}
|
|
41
|
+
function _createForOfIteratorHelper(r, e) {
|
|
42
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
43
|
+
if (!t) {
|
|
44
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
|
|
45
|
+
t && (r = t);
|
|
46
|
+
var n = 0,
|
|
47
|
+
F = function () {};
|
|
48
|
+
return {
|
|
49
|
+
s: F,
|
|
50
|
+
n: function () {
|
|
51
|
+
return n >= r.length ? {
|
|
52
|
+
done: true
|
|
53
|
+
} : {
|
|
54
|
+
done: false,
|
|
55
|
+
value: r[n++]
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
e: function (r) {
|
|
59
|
+
throw r;
|
|
60
|
+
},
|
|
61
|
+
f: F
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
65
|
+
}
|
|
66
|
+
var o,
|
|
67
|
+
a = true,
|
|
68
|
+
u = false;
|
|
69
|
+
return {
|
|
70
|
+
s: function () {
|
|
71
|
+
t = t.call(r);
|
|
72
|
+
},
|
|
73
|
+
n: function () {
|
|
74
|
+
var r = t.next();
|
|
75
|
+
return a = r.done, r;
|
|
76
|
+
},
|
|
77
|
+
e: function (r) {
|
|
78
|
+
u = true, o = r;
|
|
79
|
+
},
|
|
80
|
+
f: function () {
|
|
81
|
+
try {
|
|
82
|
+
a || null == t.return || t.return();
|
|
83
|
+
} finally {
|
|
84
|
+
if (u) throw o;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
42
89
|
function _iterableToArray(r) {
|
|
43
90
|
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
44
91
|
}
|
|
@@ -188,15 +235,17 @@ function customBuild() {
|
|
|
188
235
|
}
|
|
189
236
|
function _build() {
|
|
190
237
|
_build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(rollupOption, pluginOption) {
|
|
191
|
-
var input, output, plugins, rollupBuild, rollupOutput, _t;
|
|
238
|
+
var input, output, plugins, rollupBuild, outputIsArray, outputList, rollupOutput, _iterator, _step, out, result, _t, _t2;
|
|
192
239
|
return _regenerator().w(function (_context) {
|
|
193
|
-
while (1) switch (_context.n) {
|
|
240
|
+
while (1) switch (_context.p = _context.n) {
|
|
194
241
|
case 0:
|
|
195
242
|
input = rollupOption.input, output = rollupOption.output, plugins = rollupOption.plugins;
|
|
196
243
|
_context.n = 1;
|
|
197
244
|
return rollup.rollup({
|
|
198
245
|
input: input,
|
|
199
|
-
plugins: [].concat(_toConsumableArray(Array.isArray(plugins) ? plugins : []), [
|
|
246
|
+
plugins: [].concat(_toConsumableArray(Array.isArray(plugins) ? plugins : []), [resolve({
|
|
247
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx']
|
|
248
|
+
}), cocoMvcPlugin(pluginOption), babel({
|
|
200
249
|
extensions: ['.ts', '.tsx'],
|
|
201
250
|
plugins: [[require.resolve('@babel/plugin-proposal-decorators'), {
|
|
202
251
|
version: '2023-11'
|
|
@@ -204,33 +253,68 @@ function customBuild() {
|
|
|
204
253
|
runtime: 'automatic',
|
|
205
254
|
importSource: '@cocojs/mvc'
|
|
206
255
|
}]]
|
|
207
|
-
})])
|
|
256
|
+
})]),
|
|
257
|
+
external: [
|
|
258
|
+
/**
|
|
259
|
+
* 当打包成库时
|
|
260
|
+
* @cocojs/mvc是作为peer dependency
|
|
261
|
+
* @cocojs/mvc及其打头的依赖都作为外部依赖
|
|
262
|
+
*/
|
|
263
|
+
/^@cocojs\/mvc(\/.*)?$/]
|
|
208
264
|
});
|
|
209
265
|
case 1:
|
|
210
266
|
rollupBuild = _context.v;
|
|
267
|
+
outputIsArray = Array.isArray(output);
|
|
268
|
+
outputList = outputIsArray ? output : [output];
|
|
269
|
+
rollupOutput = [];
|
|
270
|
+
_iterator = _createForOfIteratorHelper(outputList);
|
|
271
|
+
_context.p = 2;
|
|
272
|
+
_iterator.s();
|
|
273
|
+
case 3:
|
|
274
|
+
if ((_step = _iterator.n()).done) {
|
|
275
|
+
_context.n = 9;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
out = _step.value;
|
|
211
279
|
if (!useGenerate) {
|
|
212
|
-
_context.n =
|
|
280
|
+
_context.n = 5;
|
|
213
281
|
break;
|
|
214
282
|
}
|
|
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
283
|
_context.n = 4;
|
|
223
|
-
return rollupBuild.
|
|
284
|
+
return rollupBuild.generate(out);
|
|
224
285
|
case 4:
|
|
225
286
|
_t = _context.v;
|
|
287
|
+
_context.n = 7;
|
|
288
|
+
break;
|
|
226
289
|
case 5:
|
|
227
|
-
|
|
290
|
+
_context.n = 6;
|
|
291
|
+
return rollupBuild.write(out);
|
|
292
|
+
case 6:
|
|
293
|
+
_t = _context.v;
|
|
294
|
+
case 7:
|
|
295
|
+
result = _t;
|
|
296
|
+
rollupOutput.push(result);
|
|
297
|
+
case 8:
|
|
298
|
+
_context.n = 3;
|
|
299
|
+
break;
|
|
300
|
+
case 9:
|
|
301
|
+
_context.n = 11;
|
|
302
|
+
break;
|
|
303
|
+
case 10:
|
|
304
|
+
_context.p = 10;
|
|
305
|
+
_t2 = _context.v;
|
|
306
|
+
_iterator.e(_t2);
|
|
307
|
+
case 11:
|
|
308
|
+
_context.p = 11;
|
|
309
|
+
_iterator.f();
|
|
310
|
+
return _context.f(11);
|
|
311
|
+
case 12:
|
|
228
312
|
return _context.a(2, {
|
|
229
313
|
rollupBuild: rollupBuild,
|
|
230
|
-
rollupOutput: rollupOutput
|
|
314
|
+
rollupOutput: outputIsArray ? rollupOutput : rollupOutput[0]
|
|
231
315
|
});
|
|
232
316
|
}
|
|
233
|
-
}, _callee);
|
|
317
|
+
}, _callee, null, [[2, 10, 11, 12]]);
|
|
234
318
|
}));
|
|
235
319
|
return _build.apply(this, arguments);
|
|
236
320
|
}
|
|
@@ -238,5 +322,5 @@ function customBuild() {
|
|
|
238
322
|
}
|
|
239
323
|
var bundle = customBuild();
|
|
240
324
|
|
|
325
|
+
exports.bundle = bundle;
|
|
241
326
|
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,323 @@
|
|
|
1
|
+
import { rollup } from 'rollup';
|
|
2
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
3
|
+
import babel from '@rollup/plugin-babel';
|
|
4
|
+
import { compileOneFile } from '@cocojs/compiler';
|
|
5
|
+
|
|
6
|
+
function _arrayLikeToArray(r, a) {
|
|
7
|
+
(null == a || a > r.length) && (a = r.length);
|
|
8
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
9
|
+
return n;
|
|
10
|
+
}
|
|
11
|
+
function _arrayWithoutHoles(r) {
|
|
12
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
13
|
+
}
|
|
14
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
15
|
+
try {
|
|
16
|
+
var i = n[a](c),
|
|
17
|
+
u = i.value;
|
|
18
|
+
} catch (n) {
|
|
19
|
+
return void e(n);
|
|
20
|
+
}
|
|
21
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
22
|
+
}
|
|
23
|
+
function _asyncToGenerator(n) {
|
|
24
|
+
return function () {
|
|
25
|
+
var t = this,
|
|
26
|
+
e = arguments;
|
|
27
|
+
return new Promise(function (r, o) {
|
|
28
|
+
var a = n.apply(t, e);
|
|
29
|
+
function _next(n) {
|
|
30
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
31
|
+
}
|
|
32
|
+
function _throw(n) {
|
|
33
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
34
|
+
}
|
|
35
|
+
_next(void 0);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function _createForOfIteratorHelper(r, e) {
|
|
40
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
41
|
+
if (!t) {
|
|
42
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
|
|
43
|
+
t && (r = t);
|
|
44
|
+
var n = 0,
|
|
45
|
+
F = function () {};
|
|
46
|
+
return {
|
|
47
|
+
s: F,
|
|
48
|
+
n: function () {
|
|
49
|
+
return n >= r.length ? {
|
|
50
|
+
done: true
|
|
51
|
+
} : {
|
|
52
|
+
done: false,
|
|
53
|
+
value: r[n++]
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
e: function (r) {
|
|
57
|
+
throw r;
|
|
58
|
+
},
|
|
59
|
+
f: F
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
63
|
+
}
|
|
64
|
+
var o,
|
|
65
|
+
a = true,
|
|
66
|
+
u = false;
|
|
67
|
+
return {
|
|
68
|
+
s: function () {
|
|
69
|
+
t = t.call(r);
|
|
70
|
+
},
|
|
71
|
+
n: function () {
|
|
72
|
+
var r = t.next();
|
|
73
|
+
return a = r.done, r;
|
|
74
|
+
},
|
|
75
|
+
e: function (r) {
|
|
76
|
+
u = true, o = r;
|
|
77
|
+
},
|
|
78
|
+
f: function () {
|
|
79
|
+
try {
|
|
80
|
+
a || null == t.return || t.return();
|
|
81
|
+
} finally {
|
|
82
|
+
if (u) throw o;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function _iterableToArray(r) {
|
|
88
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
89
|
+
}
|
|
90
|
+
function _nonIterableSpread() {
|
|
91
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
92
|
+
}
|
|
93
|
+
function _regenerator() {
|
|
94
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
95
|
+
var e,
|
|
96
|
+
t,
|
|
97
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
98
|
+
n = r.iterator || "@@iterator",
|
|
99
|
+
o = r.toStringTag || "@@toStringTag";
|
|
100
|
+
function i(r, n, o, i) {
|
|
101
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
102
|
+
u = Object.create(c.prototype);
|
|
103
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
104
|
+
var i,
|
|
105
|
+
c,
|
|
106
|
+
u,
|
|
107
|
+
f = 0,
|
|
108
|
+
p = o || [],
|
|
109
|
+
y = false,
|
|
110
|
+
G = {
|
|
111
|
+
p: 0,
|
|
112
|
+
n: 0,
|
|
113
|
+
v: e,
|
|
114
|
+
a: d,
|
|
115
|
+
f: d.bind(e, 4),
|
|
116
|
+
d: function (t, r) {
|
|
117
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
function d(r, n) {
|
|
121
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
122
|
+
var o,
|
|
123
|
+
i = p[t],
|
|
124
|
+
d = G.p,
|
|
125
|
+
l = i[2];
|
|
126
|
+
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));
|
|
127
|
+
}
|
|
128
|
+
if (o || r > 1) return a;
|
|
129
|
+
throw y = true, n;
|
|
130
|
+
}
|
|
131
|
+
return function (o, p, l) {
|
|
132
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
133
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
134
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
135
|
+
try {
|
|
136
|
+
if (f = 2, i) {
|
|
137
|
+
if (c || (o = "next"), t = i[o]) {
|
|
138
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
139
|
+
if (!t.done) return t;
|
|
140
|
+
u = t.value, c < 2 && (c = 0);
|
|
141
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
142
|
+
i = e;
|
|
143
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
144
|
+
} catch (t) {
|
|
145
|
+
i = e, c = 1, u = t;
|
|
146
|
+
} finally {
|
|
147
|
+
f = 1;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
value: t,
|
|
152
|
+
done: y
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
}(r, o, i), true), u;
|
|
156
|
+
}
|
|
157
|
+
var a = {};
|
|
158
|
+
function Generator() {}
|
|
159
|
+
function GeneratorFunction() {}
|
|
160
|
+
function GeneratorFunctionPrototype() {}
|
|
161
|
+
t = Object.getPrototypeOf;
|
|
162
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
163
|
+
return this;
|
|
164
|
+
}), t),
|
|
165
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
166
|
+
function f(e) {
|
|
167
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
168
|
+
}
|
|
169
|
+
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 () {
|
|
170
|
+
return this;
|
|
171
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
172
|
+
return "[object Generator]";
|
|
173
|
+
}), (_regenerator = function () {
|
|
174
|
+
return {
|
|
175
|
+
w: i,
|
|
176
|
+
m: f
|
|
177
|
+
};
|
|
178
|
+
})();
|
|
179
|
+
}
|
|
180
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
181
|
+
var i = Object.defineProperty;
|
|
182
|
+
try {
|
|
183
|
+
i({}, "", {});
|
|
184
|
+
} catch (e) {
|
|
185
|
+
i = 0;
|
|
186
|
+
}
|
|
187
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
188
|
+
function o(r, n) {
|
|
189
|
+
_regeneratorDefine(e, r, function (e) {
|
|
190
|
+
return this._invoke(r, n, e);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
r ? i ? i(e, r, {
|
|
194
|
+
value: n,
|
|
195
|
+
enumerable: !t,
|
|
196
|
+
configurable: !t,
|
|
197
|
+
writable: !t
|
|
198
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
199
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
200
|
+
}
|
|
201
|
+
function _toConsumableArray(r) {
|
|
202
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
203
|
+
}
|
|
204
|
+
function _unsupportedIterableToArray(r, a) {
|
|
205
|
+
if (r) {
|
|
206
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
207
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
208
|
+
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;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function cocoMvcPlugin() {
|
|
213
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
214
|
+
idPrefix = _ref.idPrefix;
|
|
215
|
+
return {
|
|
216
|
+
name: 'rollup-plugin-coco-mvc',
|
|
217
|
+
transform: function transform(code, id) {
|
|
218
|
+
try {
|
|
219
|
+
var output = compileOneFile(code, id, idPrefix);
|
|
220
|
+
return output;
|
|
221
|
+
} catch (e) {
|
|
222
|
+
this.error(e.message);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function customBuild() {
|
|
229
|
+
var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
230
|
+
var useGenerate = option.useGenerate;
|
|
231
|
+
function build(_x, _x2) {
|
|
232
|
+
return _build.apply(this, arguments);
|
|
233
|
+
}
|
|
234
|
+
function _build() {
|
|
235
|
+
_build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(rollupOption, pluginOption) {
|
|
236
|
+
var input, output, plugins, rollupBuild, outputIsArray, outputList, rollupOutput, _iterator, _step, out, result, _t, _t2;
|
|
237
|
+
return _regenerator().w(function (_context) {
|
|
238
|
+
while (1) switch (_context.p = _context.n) {
|
|
239
|
+
case 0:
|
|
240
|
+
input = rollupOption.input, output = rollupOption.output, plugins = rollupOption.plugins;
|
|
241
|
+
_context.n = 1;
|
|
242
|
+
return rollup({
|
|
243
|
+
input: input,
|
|
244
|
+
plugins: [].concat(_toConsumableArray(Array.isArray(plugins) ? plugins : []), [resolve({
|
|
245
|
+
extensions: ['.ts', '.tsx', '.js', '.jsx']
|
|
246
|
+
}), cocoMvcPlugin(pluginOption), babel({
|
|
247
|
+
extensions: ['.ts', '.tsx'],
|
|
248
|
+
plugins: [[require.resolve('@babel/plugin-proposal-decorators'), {
|
|
249
|
+
version: '2023-11'
|
|
250
|
+
}], [require.resolve('@babel/plugin-transform-react-jsx'), {
|
|
251
|
+
runtime: 'automatic',
|
|
252
|
+
importSource: '@cocojs/mvc'
|
|
253
|
+
}]]
|
|
254
|
+
})]),
|
|
255
|
+
external: [
|
|
256
|
+
/**
|
|
257
|
+
* 当打包成库时
|
|
258
|
+
* @cocojs/mvc是作为peer dependency
|
|
259
|
+
* @cocojs/mvc及其打头的依赖都作为外部依赖
|
|
260
|
+
*/
|
|
261
|
+
/^@cocojs\/mvc(\/.*)?$/]
|
|
262
|
+
});
|
|
263
|
+
case 1:
|
|
264
|
+
rollupBuild = _context.v;
|
|
265
|
+
outputIsArray = Array.isArray(output);
|
|
266
|
+
outputList = outputIsArray ? output : [output];
|
|
267
|
+
rollupOutput = [];
|
|
268
|
+
_iterator = _createForOfIteratorHelper(outputList);
|
|
269
|
+
_context.p = 2;
|
|
270
|
+
_iterator.s();
|
|
271
|
+
case 3:
|
|
272
|
+
if ((_step = _iterator.n()).done) {
|
|
273
|
+
_context.n = 9;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
out = _step.value;
|
|
277
|
+
if (!useGenerate) {
|
|
278
|
+
_context.n = 5;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
_context.n = 4;
|
|
282
|
+
return rollupBuild.generate(out);
|
|
283
|
+
case 4:
|
|
284
|
+
_t = _context.v;
|
|
285
|
+
_context.n = 7;
|
|
286
|
+
break;
|
|
287
|
+
case 5:
|
|
288
|
+
_context.n = 6;
|
|
289
|
+
return rollupBuild.write(out);
|
|
290
|
+
case 6:
|
|
291
|
+
_t = _context.v;
|
|
292
|
+
case 7:
|
|
293
|
+
result = _t;
|
|
294
|
+
rollupOutput.push(result);
|
|
295
|
+
case 8:
|
|
296
|
+
_context.n = 3;
|
|
297
|
+
break;
|
|
298
|
+
case 9:
|
|
299
|
+
_context.n = 11;
|
|
300
|
+
break;
|
|
301
|
+
case 10:
|
|
302
|
+
_context.p = 10;
|
|
303
|
+
_t2 = _context.v;
|
|
304
|
+
_iterator.e(_t2);
|
|
305
|
+
case 11:
|
|
306
|
+
_context.p = 11;
|
|
307
|
+
_iterator.f();
|
|
308
|
+
return _context.f(11);
|
|
309
|
+
case 12:
|
|
310
|
+
return _context.a(2, {
|
|
311
|
+
rollupBuild: rollupBuild,
|
|
312
|
+
rollupOutput: outputIsArray ? rollupOutput : rollupOutput[0]
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}, _callee, null, [[2, 10, 11, 12]]);
|
|
316
|
+
}));
|
|
317
|
+
return _build.apply(this, arguments);
|
|
318
|
+
}
|
|
319
|
+
return build;
|
|
320
|
+
}
|
|
321
|
+
var bundle = customBuild();
|
|
322
|
+
|
|
323
|
+
export { bundle, customBuild };
|
package/package.json
CHANGED
|
@@ -1,40 +1,42 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
2
|
+
"name": "@cocojs/bundle-rollup",
|
|
3
|
+
"version": "0.0.1-beta.11",
|
|
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/plugin-node-resolve": "^16.0.3",
|
|
36
|
+
"rollup": "^4.53.3",
|
|
37
|
+
"@cocojs/compiler": "0.1.0-beta.202601082202"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"jest": "jest"
|
|
41
|
+
}
|
|
42
|
+
}
|