@next-core/build-next-bricks 1.21.1 → 1.22.1
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/package.json +5 -4
- package/src/EmitBricksJsonPlugin.js +2 -0
- package/src/build.js +5 -0
- package/src/scanBricks.js +58 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/build-next-bricks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.1",
|
|
4
4
|
"description": "Build next bricks",
|
|
5
5
|
"homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/build-next-bricks",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
29
|
-
"url": "git@github.com:easyops-cn/next-core.git"
|
|
29
|
+
"url": "git@github.com:easyops-cn/next-core.git",
|
|
30
|
+
"directory": "packages/build-next-bricks"
|
|
30
31
|
},
|
|
31
32
|
"sideEffects": false,
|
|
32
33
|
"engines": {
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"webpack": "^5.91.0"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
|
-
"@next-core/brick-manifest": "^0.7.
|
|
58
|
+
"@next-core/brick-manifest": "^0.7.1"
|
|
58
59
|
},
|
|
59
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "a75d36029fc3ec34a16360265300fab9d8671c39"
|
|
60
61
|
}
|
|
@@ -15,6 +15,7 @@ export default class EmitBricksJsonPlugin {
|
|
|
15
15
|
this.bricks = options.bricks;
|
|
16
16
|
this.elements = options.elements;
|
|
17
17
|
this.processors = options.processors;
|
|
18
|
+
this.editors = options.editors;
|
|
18
19
|
this.dependencies = options.dependencies;
|
|
19
20
|
this.manifest = options.manifest;
|
|
20
21
|
this.types = options.types;
|
|
@@ -56,6 +57,7 @@ export default class EmitBricksJsonPlugin {
|
|
|
56
57
|
bricks: this.bricks,
|
|
57
58
|
elements: this.elements,
|
|
58
59
|
processors: this.processors,
|
|
60
|
+
editors: this.editors,
|
|
59
61
|
dependencies: this.dependencies,
|
|
60
62
|
filePath: jsFilePath,
|
|
61
63
|
deprecatedElements: this.deprecatedElements,
|
package/src/build.js
CHANGED
|
@@ -246,6 +246,8 @@ async function getWebpackConfig(config) {
|
|
|
246
246
|
const elements = [];
|
|
247
247
|
/** @type {string[]} */
|
|
248
248
|
const processors = [];
|
|
249
|
+
/** @type {string[]} */
|
|
250
|
+
const editors = [];
|
|
249
251
|
if (isBricks) {
|
|
250
252
|
for (const [key, val] of Object.entries(config.exposes)) {
|
|
251
253
|
const segments = key.split("/");
|
|
@@ -253,6 +255,8 @@ async function getWebpackConfig(config) {
|
|
|
253
255
|
const namespace = segments.pop();
|
|
254
256
|
if (namespace === "processors") {
|
|
255
257
|
processors.push(`${camelPackageName}.${name}`);
|
|
258
|
+
} else if (namespace === "editors") {
|
|
259
|
+
editors.push(name);
|
|
256
260
|
} else {
|
|
257
261
|
if (val[Symbol.for("noNamespace")]) {
|
|
258
262
|
elements.push(name);
|
|
@@ -510,6 +514,7 @@ async function getWebpackConfig(config) {
|
|
|
510
514
|
bricks,
|
|
511
515
|
elements,
|
|
512
516
|
processors,
|
|
517
|
+
editors,
|
|
513
518
|
dependencies: config.dependencies,
|
|
514
519
|
manifest: config.manifest,
|
|
515
520
|
types: config.types,
|
package/src/scanBricks.js
CHANGED
|
@@ -271,6 +271,62 @@ export default async function scanBricks(packageDir) {
|
|
|
271
271
|
"Please call `customProcessors.define()` only with literal string"
|
|
272
272
|
);
|
|
273
273
|
}
|
|
274
|
+
} else if (
|
|
275
|
+
callee.type === "MemberExpression" &&
|
|
276
|
+
callee.object.type === "Identifier" &&
|
|
277
|
+
callee.object.name === "customEditors" &&
|
|
278
|
+
!callee.property.computed &&
|
|
279
|
+
callee.property.name === "define" &&
|
|
280
|
+
args.length === 2
|
|
281
|
+
) {
|
|
282
|
+
const { type, value: fullName } = args[0];
|
|
283
|
+
if (type === "StringLiteral") {
|
|
284
|
+
/** @type {string | undefined} */
|
|
285
|
+
let editorNamespace;
|
|
286
|
+
/** @type {string} */
|
|
287
|
+
let editorName;
|
|
288
|
+
if (fullName.includes(".")) {
|
|
289
|
+
[editorNamespace, editorName] = fullName.split(".");
|
|
290
|
+
|
|
291
|
+
if (editorNamespace !== packageName) {
|
|
292
|
+
throw new Error(
|
|
293
|
+
`Invalid editor: "${fullName}", expecting prefixed with the package name: "${packageName}"`
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if (!validBrickName.test(fullName)) {
|
|
298
|
+
throw new Error(
|
|
299
|
+
`Invalid editor: "${fullName}", expecting: "PACKAGE-NAME.BRICK-NAME", where PACKAGE-NAME and BRICK-NAME must be lower-kebab-case, and BRICK-NAME must include a \`-\``
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
} else {
|
|
303
|
+
editorName = fullName;
|
|
304
|
+
|
|
305
|
+
if (!editorName.startsWith("eo-")) {
|
|
306
|
+
throw new Error(
|
|
307
|
+
`Invalid editor: "${editorName}", expecting prefixed with "eo-" for brick name without namespace`
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (!validCustomElementName.test(editorName)) {
|
|
312
|
+
throw new Error(
|
|
313
|
+
`Invalid editor: "${editorName}", expecting a \`-\` in editor name`
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
exposes.set(`./editors/${editorName}`, {
|
|
319
|
+
import: `./${path
|
|
320
|
+
.relative(packageDir, overrideImport || filePath)
|
|
321
|
+
.replace(/\.[^.]+$/, "")
|
|
322
|
+
.replace(/\/index$/, "")}`,
|
|
323
|
+
name: getExposeName(editorName),
|
|
324
|
+
});
|
|
325
|
+
} else {
|
|
326
|
+
throw new Error(
|
|
327
|
+
"Please call `customEditors.define()` only with literal string"
|
|
328
|
+
);
|
|
329
|
+
}
|
|
274
330
|
} else if (
|
|
275
331
|
callee.type === "MemberExpression" &&
|
|
276
332
|
callee.object.type === "Identifier" &&
|
|
@@ -799,8 +855,8 @@ export default async function scanBricks(packageDir) {
|
|
|
799
855
|
const importPath = realFilePath
|
|
800
856
|
? realFilePath
|
|
801
857
|
: importItem
|
|
802
|
-
|
|
803
|
-
|
|
858
|
+
? importItem.path
|
|
859
|
+
: filePath;
|
|
804
860
|
|
|
805
861
|
const { declaration, usedReferences } =
|
|
806
862
|
typeDeclarations.find(
|