@next-core/build-next-bricks 1.17.0 → 1.18.0
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 +2 -2
- package/src/EmitBricksJsonPlugin.js +3 -0
- package/src/build.js +43 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/build-next-bricks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
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",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@next-core/brick-manifest": "^0.7.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "48ac4bbeff115c782d19fcfce56c3a093d565438"
|
|
60
60
|
}
|
|
@@ -19,6 +19,7 @@ export default class EmitBricksJsonPlugin {
|
|
|
19
19
|
this.manifest = options.manifest;
|
|
20
20
|
this.types = options.types;
|
|
21
21
|
this.examples = options.examples;
|
|
22
|
+
this.deprecatedElements = options.deprecatedElements;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
/**
|
|
@@ -57,6 +58,7 @@ export default class EmitBricksJsonPlugin {
|
|
|
57
58
|
processors: this.processors,
|
|
58
59
|
dependencies: this.dependencies,
|
|
59
60
|
filePath: jsFilePath,
|
|
61
|
+
deprecatedElements: this.deprecatedElements,
|
|
60
62
|
},
|
|
61
63
|
null,
|
|
62
64
|
2
|
|
@@ -89,6 +91,7 @@ export default class EmitBricksJsonPlugin {
|
|
|
89
91
|
console.log("Defined elements:", this.elements);
|
|
90
92
|
console.log("Defined processors:", this.processors);
|
|
91
93
|
console.log("Found dependencies:", this.dependencies);
|
|
94
|
+
console.log("Found deprecated elements:", this.deprecatedElements);
|
|
92
95
|
callback();
|
|
93
96
|
}
|
|
94
97
|
);
|
package/src/build.js
CHANGED
|
@@ -83,20 +83,53 @@ async function getWebpackConfig(config) {
|
|
|
83
83
|
packageDir,
|
|
84
84
|
"../../shared/common-bricks/common-bricks.json"
|
|
85
85
|
);
|
|
86
|
+
|
|
87
|
+
const deprecatedBricksJsonFile = path.join(
|
|
88
|
+
packageDir,
|
|
89
|
+
"../../shared/common-bricks/deprecated-bricks.json"
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const deprecatedBricksJson = existsSync(deprecatedBricksJsonFile)
|
|
93
|
+
? JSON.parse(await readFile(deprecatedBricksJsonFile, "utf-8"))
|
|
94
|
+
: {};
|
|
95
|
+
|
|
86
96
|
if (existsSync(commonBricksJsonFile)) {
|
|
87
97
|
const commonBricksJson = JSON.parse(
|
|
88
98
|
await readFile(commonBricksJsonFile, "utf-8")
|
|
89
99
|
);
|
|
90
100
|
|
|
91
|
-
/** @type {
|
|
101
|
+
/** @type {Map<string, string | string[]>} */
|
|
92
102
|
const commonBricksMap = new Map();
|
|
93
103
|
for (const [pkg, bricks] of Object.entries(commonBricksJson)) {
|
|
94
104
|
for (const brick of bricks) {
|
|
95
105
|
const existedPkg = commonBricksMap.get(brick);
|
|
96
106
|
if (existedPkg && existedPkg !== pkg) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
107
|
+
if (Array.isArray(existedPkg)) {
|
|
108
|
+
const pkgs = existedPkg.concat(pkg);
|
|
109
|
+
|
|
110
|
+
const othersPkgs = pkgs.filter(
|
|
111
|
+
(p) => !deprecatedBricksJson[p]?.includes(brick)
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
throw new Error(
|
|
115
|
+
`Conflicted common brick: "${brick}" in package "${othersPkgs[0]}" and "${othersPkgs[1]}"`
|
|
116
|
+
);
|
|
117
|
+
} else {
|
|
118
|
+
const existedPkgDeprecated = deprecatedBricksJson[existedPkg];
|
|
119
|
+
const pkgDeprecated = deprecatedBricksJson[pkg];
|
|
120
|
+
|
|
121
|
+
if (
|
|
122
|
+
(existedPkgDeprecated && existedPkgDeprecated.includes(brick)) ||
|
|
123
|
+
(pkgDeprecated && pkgDeprecated.includes(brick))
|
|
124
|
+
) {
|
|
125
|
+
commonBricksMap.set(brick, [pkg].concat(existedPkg));
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
throw new Error(
|
|
130
|
+
`Conflicted common brick: "${brick}" in package "${existedPkg}" and "${pkg}"`
|
|
131
|
+
);
|
|
132
|
+
}
|
|
100
133
|
}
|
|
101
134
|
commonBricksMap.set(brick, pkg);
|
|
102
135
|
}
|
|
@@ -470,6 +503,12 @@ async function getWebpackConfig(config) {
|
|
|
470
503
|
manifest: config.manifest,
|
|
471
504
|
types: config.types,
|
|
472
505
|
examples: config.examples,
|
|
506
|
+
deprecatedElements: Object.prototype.hasOwnProperty.call(
|
|
507
|
+
deprecatedBricksJson,
|
|
508
|
+
packageName
|
|
509
|
+
)
|
|
510
|
+
? deprecatedBricksJson[packageName]
|
|
511
|
+
: undefined,
|
|
473
512
|
}),
|
|
474
513
|
]
|
|
475
514
|
: []),
|