@douyinfe/semi-webpack-plugin 2.59.0-alpha.0 → 2.59.0-beta.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/lib/componentDependentTree.d.ts +69 -0
- package/lib/componentDependentTree.js +72 -0
- package/lib/componentDependentTree.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/semi-extract-css-content-loader.d.ts +11 -0
- package/lib/semi-extract-css-content-loader.js +29 -0
- package/lib/semi-extract-css-content-loader.js.map +1 -0
- package/lib/semi-theme-loader.js +9 -2
- package/lib/semi-theme-loader.js.map +1 -1
- package/lib/semi-web-component-loader.d.ts +1 -0
- package/lib/semi-web-component-loader.js +123 -0
- package/lib/semi-web-component-loader.js.map +1 -0
- package/lib/semi-webpack-plugin.d.ts +3 -0
- package/lib/semi-webpack-plugin.js +66 -25
- package/lib/semi-webpack-plugin.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
declare const dependentTree: {
|
|
2
|
+
Anchor: string[];
|
|
3
|
+
AutoComplete: string[];
|
|
4
|
+
Avatar: any;
|
|
5
|
+
AvatarGroup: any;
|
|
6
|
+
BackTop: string[];
|
|
7
|
+
Badge: any;
|
|
8
|
+
Banner: string[];
|
|
9
|
+
Breadcrumb: string[];
|
|
10
|
+
Button: string[];
|
|
11
|
+
Calendar: string[];
|
|
12
|
+
Card: string[];
|
|
13
|
+
Carousel: string[];
|
|
14
|
+
Cascader: string[];
|
|
15
|
+
Checkbox: string[];
|
|
16
|
+
CheckboxGroup: string[];
|
|
17
|
+
Collapse: string[];
|
|
18
|
+
Collapsible: any;
|
|
19
|
+
DatePicker: string[];
|
|
20
|
+
Descriptions: any;
|
|
21
|
+
Divider: any;
|
|
22
|
+
Dropdown: string[];
|
|
23
|
+
Empty: string[];
|
|
24
|
+
Form: string[];
|
|
25
|
+
Row: any;
|
|
26
|
+
Col: any;
|
|
27
|
+
Highlight: any;
|
|
28
|
+
IconButton: string[];
|
|
29
|
+
Image: string[];
|
|
30
|
+
Input: string[];
|
|
31
|
+
InputGroup: string[];
|
|
32
|
+
TextArea: string[];
|
|
33
|
+
InputNumber: string[];
|
|
34
|
+
Layout: any;
|
|
35
|
+
Modal: string[];
|
|
36
|
+
Navigation: string[];
|
|
37
|
+
Notification: string[];
|
|
38
|
+
OverflowList: any;
|
|
39
|
+
Pagination: string[];
|
|
40
|
+
Popconfirm: string[];
|
|
41
|
+
Popover: string[];
|
|
42
|
+
Portal: any;
|
|
43
|
+
Progress: any;
|
|
44
|
+
Radio: string[];
|
|
45
|
+
Rating: string[];
|
|
46
|
+
ScrollList: any;
|
|
47
|
+
Select: string[];
|
|
48
|
+
SideSheet: string[];
|
|
49
|
+
Skeleton: any;
|
|
50
|
+
Slider: string[];
|
|
51
|
+
Space: any;
|
|
52
|
+
Spin: any;
|
|
53
|
+
Steps: string[];
|
|
54
|
+
Switch: string[];
|
|
55
|
+
Table: string[];
|
|
56
|
+
Tabs: string[];
|
|
57
|
+
Tag: string[];
|
|
58
|
+
TagGroup: string[];
|
|
59
|
+
TagInput: string[];
|
|
60
|
+
Timeline: any;
|
|
61
|
+
Toast: string[];
|
|
62
|
+
Tooltip: string[];
|
|
63
|
+
Transfer: string[];
|
|
64
|
+
Tree: string[];
|
|
65
|
+
TreeSelect: string[];
|
|
66
|
+
Typography: string[];
|
|
67
|
+
Upload: string[];
|
|
68
|
+
};
|
|
69
|
+
export default dependentTree;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const dependentTree = {
|
|
4
|
+
"Anchor": ["Typography"],
|
|
5
|
+
"AutoComplete": ["Spin", "Popover", "Input", "Icon"],
|
|
6
|
+
"Avatar": [],
|
|
7
|
+
"AvatarGroup": [],
|
|
8
|
+
"BackTop": ["Icon"],
|
|
9
|
+
"Badge": [],
|
|
10
|
+
"Banner": ["IconButton", "Typography", "Icon"],
|
|
11
|
+
"Breadcrumb": ["Popover", "Typography", "Icon"],
|
|
12
|
+
"Button": ["Icon"],
|
|
13
|
+
"Calendar": ["Popover", "Button", "Icon"],
|
|
14
|
+
"Card": ["Space", "Skeleton", "Typography"],
|
|
15
|
+
"Carousel": ["Icon"],
|
|
16
|
+
"Cascader": ["Input", "Popover", "Tag", "TagInput", "Spin", "Checkbox", "Icon"],
|
|
17
|
+
"Checkbox": ["Icon"],
|
|
18
|
+
"CheckboxGroup": ["Icon"],
|
|
19
|
+
"Collapse": ["Collapsible", "Icon"],
|
|
20
|
+
"Collapsible": [],
|
|
21
|
+
"DatePicker": ["Button", "Input", "IconButton", "Icon", "Typography", "ScrollList", "Icon"],
|
|
22
|
+
"Descriptions": [],
|
|
23
|
+
"Divider": [],
|
|
24
|
+
"Dropdown": ["Tooltip", "Icon"],
|
|
25
|
+
"Empty": ["Typography"],
|
|
26
|
+
"Form": ["Row", "Col", "Icon"],
|
|
27
|
+
"Row": [],
|
|
28
|
+
"Col": [],
|
|
29
|
+
"Highlight": [],
|
|
30
|
+
"IconButton": ["Button", "Spin", "Icon"],
|
|
31
|
+
"Image": ["Skeleton", "Divider", "Tooltip", "Slider", "Spin", "Portal", "Icon"],
|
|
32
|
+
"Input": ["Icon"],
|
|
33
|
+
"InputGroup": ["Form"],
|
|
34
|
+
"TextArea": ["Icon"],
|
|
35
|
+
"InputNumber": ["Input", "Icon"],
|
|
36
|
+
"Layout": [],
|
|
37
|
+
"Modal": ["Button", "Portal", "Typography", "Icon"],
|
|
38
|
+
"Navigation": ["Button", "Tooltip", "Dropdown", "Collapsible", "Icon"],
|
|
39
|
+
"Notification": ["Button", "Icon"],
|
|
40
|
+
"OverflowList": [],
|
|
41
|
+
"Pagination": ["Select", "InputNumber", "Popover", "Icon"],
|
|
42
|
+
"Popconfirm": ["Popover", "Button", "Icon"],
|
|
43
|
+
"Popover": ["Tooltip"],
|
|
44
|
+
"Portal": [],
|
|
45
|
+
"Progress": [],
|
|
46
|
+
"Radio": ["Icon"],
|
|
47
|
+
"Rating": ["Icon", "Tooltip"],
|
|
48
|
+
"ScrollList": [],
|
|
49
|
+
"Select": ["Tag", "OverflowList", "Space", "Typography", "Spin", "Popover", "Icon"],
|
|
50
|
+
"SideSheet": ["[Portal", "Button", "Icon"],
|
|
51
|
+
"Skeleton": [],
|
|
52
|
+
"Slider": ["Tooltip"],
|
|
53
|
+
"Space": [],
|
|
54
|
+
"Spin": [],
|
|
55
|
+
"Steps": ["Row", "Col", "Icon"],
|
|
56
|
+
"Switch": ["Spin"],
|
|
57
|
+
"Table": ["Radio", "Checkbox", "Dropdown", "Spin", "Pagination", "Icon"],
|
|
58
|
+
"Tabs": ["OverflowList", "Dropdown", "Button", "Icon"],
|
|
59
|
+
"Tag": ["Icon", "Popover", "Avatar"],
|
|
60
|
+
"TagGroup": ["Icon", "Popover", "Avatar"],
|
|
61
|
+
"TagInput": ["Tag", "Input", "Popover", "Icon"],
|
|
62
|
+
"Timeline": [],
|
|
63
|
+
"Toast": ["Button", "Icon"],
|
|
64
|
+
"Tooltip": ["Portal"],
|
|
65
|
+
"Transfer": ["Input", "Checkbox", "Tree", "Button", "Spin", "Icon"],
|
|
66
|
+
"Tree": ["Input", "Checkbox", "Spin", "Collapsible", "Icon"],
|
|
67
|
+
"TreeSelect": ["Tag", "TagInput", "Checkbox", "Popover", "Input", "Icon"],
|
|
68
|
+
"Typography": ["Popover", "Tooltip", "Icon"],
|
|
69
|
+
"Upload": ["Button", "Progress", "Tooltip", "Spin", "Icon"]
|
|
70
|
+
};
|
|
71
|
+
exports.default = dependentTree;
|
|
72
|
+
//# sourceMappingURL=componentDependentTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"componentDependentTree.js","sourceRoot":"","sources":["../src/componentDependentTree.ts"],"names":[],"mappings":";;AAAA,MAAM,aAAa,GAAG;IAClB,QAAQ,EAAE,CA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AAE,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC;IACxE,MAAM,EAAE,CAAC,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC;IACtD,KAAK,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC;IACpC,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,CAAC;IACzC,UAAU,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC;IAC/C,UAAU,EAAE,EAAS;IACrB,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,CAAC,QAAQ,CAAC;IACrB,UAAU,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;IACnE,MAAM,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC;IAC5D,YAAY,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC;IACzE,YAAY,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC;IAC5C,QAAQ,EAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC;CAC9D,CAAC;AAEF,kBAAe,aAAa,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export { default, SemiWebpackPluginOptions, SemiThemeOptions, WebpackContext } f
|
|
|
2
2
|
export { default as semiThemeLoader } from './semi-theme-loader';
|
|
3
3
|
export { default as semiPrefixLoader } from './semi-prefix-loader';
|
|
4
4
|
export { default as semiSourceSuffixLoader } from './semi-source-suffix-loader';
|
|
5
|
+
export { default as semiWebComponentLoader } from './semi-web-component-loader';
|
|
6
|
+
export { default as semiExtractCssContentLoader } from './semi-extract-css-content-loader';
|
package/lib/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.semiSourceSuffixLoader = exports.semiPrefixLoader = exports.semiThemeLoader = exports.default = void 0;
|
|
6
|
+
exports.semiExtractCssContentLoader = exports.semiWebComponentLoader = exports.semiSourceSuffixLoader = exports.semiPrefixLoader = exports.semiThemeLoader = exports.default = void 0;
|
|
7
7
|
var semi_webpack_plugin_1 = require("./semi-webpack-plugin");
|
|
8
8
|
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(semi_webpack_plugin_1).default; } });
|
|
9
9
|
var semi_theme_loader_1 = require("./semi-theme-loader");
|
|
@@ -12,4 +12,8 @@ var semi_prefix_loader_1 = require("./semi-prefix-loader");
|
|
|
12
12
|
Object.defineProperty(exports, "semiPrefixLoader", { enumerable: true, get: function () { return __importDefault(semi_prefix_loader_1).default; } });
|
|
13
13
|
var semi_source_suffix_loader_1 = require("./semi-source-suffix-loader");
|
|
14
14
|
Object.defineProperty(exports, "semiSourceSuffixLoader", { enumerable: true, get: function () { return __importDefault(semi_source_suffix_loader_1).default; } });
|
|
15
|
+
var semi_web_component_loader_1 = require("./semi-web-component-loader");
|
|
16
|
+
Object.defineProperty(exports, "semiWebComponentLoader", { enumerable: true, get: function () { return __importDefault(semi_web_component_loader_1).default; } });
|
|
17
|
+
var semi_extract_css_content_loader_1 = require("./semi-extract-css-content-loader");
|
|
18
|
+
Object.defineProperty(exports, "semiExtractCssContentLoader", { enumerable: true, get: function () { return __importDefault(semi_extract_css_content_loader_1).default; } });
|
|
15
19
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,6DAA4G;AAAnG,+HAAA,OAAO,OAAA;AAChB,yDAAiE;AAAxD,qIAAA,OAAO,OAAmB;AACnC,2DAAmE;AAA1D,uIAAA,OAAO,OAAoB;AACpC,yEAAgF;AAAvE,oJAAA,OAAO,OAA0B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,6DAA4G;AAAnG,+HAAA,OAAO,OAAA;AAChB,yDAAiE;AAAxD,qIAAA,OAAO,OAAmB;AACnC,2DAAmE;AAA1D,uIAAA,OAAO,OAAoB;AACpC,yEAAgF;AAAvE,oJAAA,OAAO,OAA0B;AAC1C,yEAAgF;AAAvE,oJAAA,OAAO,OAA0B;AAC1C,qFAA2F;AAAlF,+JAAA,OAAO,OAA+B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {*} source
|
|
4
|
+
* @returns string
|
|
5
|
+
* @description
|
|
6
|
+
* 此 loader 用于从 css-loader 处理后的 js 代码中获取纯 css 样式字符串
|
|
7
|
+
* source 是经过 css-loader 处理后的 js 代码。要获取其中的 css 样式字符串,需经过如下操作:
|
|
8
|
+
* 1. 通过识别module.id, "做为开头,", ""]);作为结尾拿到中间的 css 代码
|
|
9
|
+
* 2. 将 文本中的 \n 替换为空字符串
|
|
10
|
+
*/
|
|
11
|
+
export default function semiExtractCssContentLoader(source: string): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {*} source
|
|
5
|
+
* @returns string
|
|
6
|
+
* @description
|
|
7
|
+
* 此 loader 用于从 css-loader 处理后的 js 代码中获取纯 css 样式字符串
|
|
8
|
+
* source 是经过 css-loader 处理后的 js 代码。要获取其中的 css 样式字符串,需经过如下操作:
|
|
9
|
+
* 1. 通过识别module.id, "做为开头,", ""]);作为结尾拿到中间的 css 代码
|
|
10
|
+
* 2. 将 文本中的 \n 替换为空字符串
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
function semiExtractCssContentLoader(source) {
|
|
14
|
+
const beginContent = 'module.id, "';
|
|
15
|
+
const endContent = '", ""]);';
|
|
16
|
+
let begInIndex = source.indexOf(beginContent);
|
|
17
|
+
let endIndex = source.length;
|
|
18
|
+
let result = source;
|
|
19
|
+
if (begInIndex !== -1) {
|
|
20
|
+
endIndex = source.lastIndexOf(endContent);
|
|
21
|
+
if (endIndex !== -1) {
|
|
22
|
+
result = source.slice(begInIndex + beginContent.length, endIndex);
|
|
23
|
+
result = result.replace(/\\n/g, "");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
exports.default = semiExtractCssContentLoader;
|
|
29
|
+
//# sourceMappingURL=semi-extract-css-content-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semi-extract-css-content-loader.js","sourceRoot":"","sources":["../src/semi-extract-css-content-loader.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAEH,SAAwB,2BAA2B,CAAC,MAAc;IAC9D,MAAM,YAAY,GAAG,cAAc,CAAC;IACpC,MAAM,UAAU,GAAG,UAAU,CAAC;IAC9B,IAAI,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC9C,IAAI,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7B,IAAI,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE;QACnB,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAC1C,IAAI,QAAQ,KAAK,CAAC,CAAC,EAAE;YACjB,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAClE,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;SACvC;KACJ;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAdD,8CAcC"}
|
package/lib/semi-theme-loader.js
CHANGED
|
@@ -7,7 +7,9 @@ const loader_utils_1 = __importDefault(require("loader-utils"));
|
|
|
7
7
|
const enhanced_resolve_1 = __importDefault(require("enhanced-resolve"));
|
|
8
8
|
const componentName_1 = __importDefault(require("./componentName"));
|
|
9
9
|
function SemiThemeLoader(source) {
|
|
10
|
+
var _a;
|
|
10
11
|
const query = loader_utils_1.default.getOptions ? loader_utils_1.default.getOptions(this) : loader_utils_1.default.parseQuery(this.query);
|
|
12
|
+
const cssLayer = (_a = query.cssLayer) !== null && _a !== void 0 ? _a : false;
|
|
11
13
|
const theme = query.name || '@douyinfe/semi-theme-default';
|
|
12
14
|
// always inject
|
|
13
15
|
const scssVarStr = `@import "~${theme}/scss/index.scss";\n`;
|
|
@@ -53,6 +55,7 @@ function SemiThemeLoader(source) {
|
|
|
53
55
|
// inject prefix
|
|
54
56
|
const prefixCls = query.prefixCls || 'semi';
|
|
55
57
|
const prefixClsStr = `$prefix: '${prefixCls}';\n`;
|
|
58
|
+
let finalCSS = "";
|
|
56
59
|
if (shouldInject) {
|
|
57
60
|
const customStr = (() => {
|
|
58
61
|
let customStr = '';
|
|
@@ -76,11 +79,15 @@ function SemiThemeLoader(source) {
|
|
|
76
79
|
}
|
|
77
80
|
return `body:not(:not(body)){${customStr}};`;
|
|
78
81
|
})();
|
|
79
|
-
|
|
82
|
+
finalCSS = `${animationStr}${cssVarStr}${scssVarStr}${prefixClsStr}${fileStr}${customStr}`;
|
|
80
83
|
}
|
|
81
84
|
else {
|
|
82
|
-
|
|
85
|
+
finalCSS = `${scssVarStr}${prefixClsStr}${fileStr}`;
|
|
83
86
|
}
|
|
87
|
+
if (cssLayer) {
|
|
88
|
+
finalCSS = `@layer semi{${finalCSS}}`;
|
|
89
|
+
}
|
|
90
|
+
return finalCSS;
|
|
84
91
|
}
|
|
85
92
|
exports.default = SemiThemeLoader;
|
|
86
93
|
//# sourceMappingURL=semi-theme-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semi-theme-loader.js","sourceRoot":"","sources":["../src/semi-theme-loader.ts"],"names":[],"mappings":";;;;;AAAA,gEAAuC;AACvC,wEAAuC;AACvC,oEAAwD;AAExD,SAAwB,eAAe,CAAC,MAAc
|
|
1
|
+
{"version":3,"file":"semi-theme-loader.js","sourceRoot":"","sources":["../src/semi-theme-loader.ts"],"names":[],"mappings":";;;;;AAAA,gEAAuC;AACvC,wEAAuC;AACvC,oEAAwD;AAExD,SAAwB,eAAe,CAAC,MAAc;;IAClD,MAAM,KAAK,GAAG,sBAAW,CAAC,UAAU,CAAC,CAAC,CAAC,sBAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,sBAAW,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzG,MAAM,QAAQ,GAAG,MAAA,KAAK,CAAC,QAAQ,mCAAI,KAAgB,CAAC;IACpD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,IAAI,8BAA8B,CAAC;IAC3D,gBAAgB;IAChB,MAAM,UAAU,GAAG,aAAa,KAAK,sBAAsB,CAAC;IAC5D,cAAc;IACd,MAAM,SAAS,GAAG,aAAa,KAAK,uBAAuB,CAAC;IAC5D,IAAI,YAAY,GAAG,aAAa,KAAK,0BAA0B,CAAC;IAEhE,IAAI;QACA,0BAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,KAAK,sBAAsB,CAAC,CAAC;KAC9D;IAAC,OAAO,CAAC,EAAE;QACR,YAAY,GAAG,EAAE,CAAC,CAAC,2BAA2B;KACjD;IAGD,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAElD,IAAI,OAAO,GAA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EAAE;YACpB,IAAI,SAAS,GAAG,EAAE,CAAC;YACnB,IAAI;gBACA,IAAI,CAAC,0BAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,KAAK,mBAAmB,CAAC,EAAE;oBAC1D,OAAO,EAAE,CAAC;iBACb;gBACD,MAAM,uBAAuB,GAAa;oBACtC,GAAG,uBAAyB;iBAC/B,CAAC;gBACF,IAAI,kBAAkB,EAAE;oBACpB,uBAAuB,CAAC,IAAI,CAAC,GAAG,KAAK,kBAAkB,CAAC,CAAC;iBAC5D;gBACD,uBAAuB,CAAC,IAAI,CAAC,GAAG,KAAK,mBAAmB,CAAC,CAAC;gBAC1D,SAAS,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;oBACxC,OAAO,aAAa,CAAC,IAAI,CAAC;gBAC9B,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;aAEpC;YAAC,OAAO,CAAC,EAAE;gBACR,SAAS,GAAG,EAAE,CAAC,CAAC,2BAA2B;aAC9C;YACD,OAAO,wBAAwB,SAAS,IAAI,CAAC;QACjD,CAAC,CAAC,EAAE,CAAC;QAEL,QAAQ,GAAG,GAAG,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,GAAG,OAAO,GAAG,SAAS,EAAE,CAAC;KAC9F;SAAM;QACH,QAAQ,GAAG,GAAG,UAAU,GAAG,YAAY,GAAG,OAAO,EAAE,CAAC;KACvD;IAED,IAAI,QAAQ,EAAE;QACV,QAAQ,GAAG,eAAe,QAAQ,GAAG,CAAC;KACzC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC;AA3FD,kCA2FC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function semiWebComponentLoader(source: string): string;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs = require('fs');
|
|
7
|
+
const componentDependentTree_1 = __importDefault(require("./componentDependentTree"));
|
|
8
|
+
function getAllComponents(components) {
|
|
9
|
+
const originComponents = new Set(components);
|
|
10
|
+
const resultComponents = new Set();
|
|
11
|
+
// 对特殊组件做特殊处理,因为这些组件的样式文件名和组件名不一致,需要手动映射
|
|
12
|
+
const specialCaseBefore = {
|
|
13
|
+
'AvatarGroup': 'Avatar',
|
|
14
|
+
'CheckboxGroup': 'Checkbox',
|
|
15
|
+
'TagGroup': 'Tag'
|
|
16
|
+
};
|
|
17
|
+
/*
|
|
18
|
+
对特殊组件做特殊处理,因为这些组件的样式文件名和组件名不一致,需要手动映射
|
|
19
|
+
同时由于以下原因:
|
|
20
|
+
1. 组件所依赖组件和被映射的组件不同,因此应该在获取到依赖组件之后,再做映射
|
|
21
|
+
e.g InputGroup 依赖 Form 组件,其样式存储在 input.scss 中,
|
|
22
|
+
而 Input 不依赖 Form 组件,因此对于 InputGroup,需要拿到依赖组件,再做映射
|
|
23
|
+
2. 由于组件是其他组件的依赖组件,因此需要在获取到依赖组件之后,再做映射
|
|
24
|
+
e.g 比如 Row 是 Form 组件的依赖,因此需要在获取到依赖组件之后,再做映射
|
|
25
|
+
*/
|
|
26
|
+
const specialCaseAfter = {
|
|
27
|
+
"InputGroup": "Input",
|
|
28
|
+
'Row': 'Grid',
|
|
29
|
+
'Col': 'Grid',
|
|
30
|
+
};
|
|
31
|
+
Object.keys(specialCaseBefore).map(keyComponent => {
|
|
32
|
+
if (originComponents.has(keyComponent)) {
|
|
33
|
+
originComponents.delete(keyComponent);
|
|
34
|
+
originComponents.add(specialCaseBefore[keyComponent]);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
function getDependentComponents(components) {
|
|
38
|
+
components.forEach((component) => {
|
|
39
|
+
if (!resultComponents.has(component)) {
|
|
40
|
+
const dependents = componentDependentTree_1.default[component];
|
|
41
|
+
dependents === null || dependents === void 0 ? void 0 : dependents.forEach((element) => {
|
|
42
|
+
getDependentComponents([element]);
|
|
43
|
+
});
|
|
44
|
+
resultComponents.add(component);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
getDependentComponents(Array.from(originComponents));
|
|
49
|
+
Object.keys(specialCaseAfter).map(keyComponent => {
|
|
50
|
+
if (resultComponents.has(keyComponent)) {
|
|
51
|
+
resultComponents.delete(keyComponent);
|
|
52
|
+
resultComponents.add(specialCaseAfter[keyComponent]);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return Array.from(resultComponents);
|
|
56
|
+
}
|
|
57
|
+
function getScssImportPaths(components) {
|
|
58
|
+
const pathsObj = {
|
|
59
|
+
IconPath: '@douyinfe/semi-icons/lib/es/styles/icons.scss',
|
|
60
|
+
basePath: '@douyinfe/semi-ui/lib/es/_base/base.scss',
|
|
61
|
+
foundationPath: '@douyinfe/semi-foundation/lib/es/'
|
|
62
|
+
};
|
|
63
|
+
const specialCase = {
|
|
64
|
+
'Icon': pathsObj.IconPath,
|
|
65
|
+
'Base': pathsObj.basePath,
|
|
66
|
+
'Portal': `${pathsObj.foundationPath}_portal/portal.scss`,
|
|
67
|
+
"TextArea": `${pathsObj.foundationPath}input/textarea.scss`,
|
|
68
|
+
"IconButton": `${pathsObj.foundationPath}button/iconButton.scss`,
|
|
69
|
+
};
|
|
70
|
+
const cssPaths = ["Base", ...components].map(componentName => {
|
|
71
|
+
const lowFirstLetter = componentName.slice(0, 1).toLowerCase() + componentName.slice(1);
|
|
72
|
+
let pathName = '';
|
|
73
|
+
if (specialCase[componentName]) {
|
|
74
|
+
pathName = specialCase[componentName];
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
pathName = `${pathsObj.foundationPath}${lowFirstLetter}/${lowFirstLetter}.scss`;
|
|
78
|
+
}
|
|
79
|
+
return pathName;
|
|
80
|
+
});
|
|
81
|
+
const importFuncName = `
|
|
82
|
+
async function importSemiComponentStyle(componentsStr, root, cb){
|
|
83
|
+
const modules = await Promise.all([
|
|
84
|
+
${cssPaths.map(path => `import("${path}")`).join(',')}
|
|
85
|
+
]);
|
|
86
|
+
const styleStr = modules.map(module => {
|
|
87
|
+
const cssContent = module.default;
|
|
88
|
+
return cssContent;
|
|
89
|
+
});
|
|
90
|
+
styleStr.reverse().forEach(css => {
|
|
91
|
+
const style = document.createElement('style');
|
|
92
|
+
style.innerHTML = css;
|
|
93
|
+
root.prepend(style);
|
|
94
|
+
});
|
|
95
|
+
if(typeof cb === 'function') {
|
|
96
|
+
cb();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
return importFuncName;
|
|
101
|
+
}
|
|
102
|
+
function semiWebComponentLoader(source) {
|
|
103
|
+
/*SEMI_INSERT_STYLE_BEGIN[需要插入样式的组件]SEMI_INSERT_STYLE_END*/
|
|
104
|
+
const beginContent = 'SEMI_INSERT_STYLE_BEGIN';
|
|
105
|
+
const beginIndex = source.indexOf(beginContent);
|
|
106
|
+
if (beginIndex !== -1) {
|
|
107
|
+
const endIndex = source.indexOf('SEMI_INSERT_STYLE_END');
|
|
108
|
+
if (endIndex === -1) {
|
|
109
|
+
throw new Error('SEMI_INSERT_STYLE_END not found');
|
|
110
|
+
}
|
|
111
|
+
const componentsStr = source.slice(beginIndex + beginContent.length, endIndex);
|
|
112
|
+
const componentsArr = JSON.parse(componentsStr);
|
|
113
|
+
const allComponents = getAllComponents(componentsArr);
|
|
114
|
+
// console.log('allComponents', allComponents);
|
|
115
|
+
const importFuncName = getScssImportPaths(allComponents);
|
|
116
|
+
const result = source + importFuncName;
|
|
117
|
+
// console.log('result', result);
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
return source;
|
|
121
|
+
}
|
|
122
|
+
exports.default = semiWebComponentLoader;
|
|
123
|
+
//# sourceMappingURL=semi-web-component-loader.js.map
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D,yCAoBC"}
|
|
@@ -9,6 +9,7 @@ export interface ExtractCssOptions {
|
|
|
9
9
|
}
|
|
10
10
|
export interface SemiWebpackPluginOptions {
|
|
11
11
|
theme?: string | SemiThemeOptions;
|
|
12
|
+
cssLayer?: boolean;
|
|
12
13
|
prefixCls?: string;
|
|
13
14
|
variables?: {
|
|
14
15
|
[key: string]: string | number;
|
|
@@ -19,6 +20,7 @@ export interface SemiWebpackPluginOptions {
|
|
|
19
20
|
webpackContext?: WebpackContext;
|
|
20
21
|
extractCssOptions?: ExtractCssOptions;
|
|
21
22
|
overrideStylesheetLoaders?: (loaders: any[]) => any[];
|
|
23
|
+
webComponentPath?: string | RegExp;
|
|
22
24
|
}
|
|
23
25
|
export interface SemiThemeOptions {
|
|
24
26
|
name?: string;
|
|
@@ -27,6 +29,7 @@ export default class SemiWebpackPlugin {
|
|
|
27
29
|
options: SemiWebpackPluginOptions;
|
|
28
30
|
constructor(options: SemiWebpackPluginOptions);
|
|
29
31
|
apply(compiler: Compiler | LegacyCompiler): void;
|
|
32
|
+
webComponentAdapter(module: any): void;
|
|
30
33
|
omitCss(module: any): void;
|
|
31
34
|
customTheme(module: any): void;
|
|
32
35
|
customPrefix(module: any, prefix: string): void;
|
|
@@ -18,34 +18,52 @@ class SemiWebpackPlugin {
|
|
|
18
18
|
if (!NormalModule)
|
|
19
19
|
NormalModule = require('webpack/lib/NormalModule');
|
|
20
20
|
compiler.hooks.compilation.tap('SemiPlugin', (compilation) => {
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
if (NormalModule.getCompilationHooks) {
|
|
22
|
+
NormalModule.getCompilationHooks(compilation).loader.tap('SemiPlugin', (context, module) => {
|
|
23
|
+
if (this.options.omitCss) {
|
|
24
|
+
this.omitCss(module);
|
|
25
|
+
if (!this.options.webComponentPath) {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
28
|
+
}
|
|
29
|
+
this.customTheme(module);
|
|
30
|
+
if (this.options.prefixCls) {
|
|
31
|
+
this.customPrefix(module, this.options.prefixCls);
|
|
32
|
+
}
|
|
33
|
+
if (this.options.webComponentPath) {
|
|
34
|
+
this.webComponentAdapter(module);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
compilation.hooks.normalModuleLoader.tap('SemiPlugin', (context, module) => {
|
|
40
|
+
if (this.options.omitCss) {
|
|
41
|
+
this.omitCss(module);
|
|
42
|
+
if (!this.options.webComponentPath) {
|
|
38
43
|
return;
|
|
39
44
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
45
|
+
}
|
|
46
|
+
this.customTheme(module);
|
|
47
|
+
if (this.options.prefixCls) {
|
|
48
|
+
this.customPrefix(module, this.options.prefixCls);
|
|
49
|
+
}
|
|
50
|
+
if (this.options.webComponentPath) {
|
|
51
|
+
this.webComponentAdapter(module);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
46
54
|
}
|
|
47
55
|
});
|
|
48
56
|
}
|
|
57
|
+
webComponentAdapter(module) {
|
|
58
|
+
const compatiblePath = (0, utils_1.transformPath)(module.resource);
|
|
59
|
+
const reg = this.options.webComponentPath instanceof RegExp ? this.options.webComponentPath : /src\/([^/]+\/)*[^/]+\.(ts|tsx|js|jsx)$/;
|
|
60
|
+
if (reg.test(compatiblePath)) {
|
|
61
|
+
module.loaders = module.loaders || [];
|
|
62
|
+
module.loaders.push({
|
|
63
|
+
loader: path_1.default.join(__dirname, 'semi-web-component-loader')
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
49
67
|
omitCss(module) {
|
|
50
68
|
const compatiblePath = (0, utils_1.transformPath)(module.resource);
|
|
51
69
|
if (/@douyinfe\/semi-(ui|icons)\/lib\/.+\.js$/.test(compatiblePath)) {
|
|
@@ -68,8 +86,11 @@ class SemiWebpackPlugin {
|
|
|
68
86
|
const scssLoader = require.resolve('sass-loader');
|
|
69
87
|
const cssLoader = require.resolve('css-loader');
|
|
70
88
|
const styleLoader = require.resolve('style-loader');
|
|
71
|
-
const
|
|
72
|
-
|
|
89
|
+
const extraCssLoader = path_1.default.join(__dirname, 'semi-extract-css-content-loader');
|
|
90
|
+
const rawLoader = require.resolve('raw-loader');
|
|
91
|
+
const semiSemiLoaderOptions = typeof this.options.theme === 'object' ? Object.assign(Object.assign({}, this.options.theme), { cssLayer: this.options.cssLayer }) : {
|
|
92
|
+
name: this.options.theme,
|
|
93
|
+
cssLayer: this.options.cssLayer
|
|
73
94
|
};
|
|
74
95
|
if (!this.hasSemiThemeLoader(module.loaders)) {
|
|
75
96
|
const lastLoader = this.options.extractCssOptions ? {
|
|
@@ -78,8 +99,15 @@ class SemiWebpackPlugin {
|
|
|
78
99
|
} : {
|
|
79
100
|
loader: styleLoader
|
|
80
101
|
};
|
|
81
|
-
const
|
|
82
|
-
|
|
102
|
+
const getRawCssLoaders = [
|
|
103
|
+
{
|
|
104
|
+
loader: rawLoader
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
loader: extraCssLoader
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
const commonLoaderList = [
|
|
83
111
|
{
|
|
84
112
|
loader: cssLoader,
|
|
85
113
|
options: {
|
|
@@ -93,6 +121,19 @@ class SemiWebpackPlugin {
|
|
|
93
121
|
options: Object.assign(Object.assign({}, semiSemiLoaderOptions), { prefixCls: this.options.prefixCls, variables: this.convertMapToString(this.options.variables || {}), include: this.options.include })
|
|
94
122
|
}
|
|
95
123
|
];
|
|
124
|
+
let loaderList = commonLoaderList;
|
|
125
|
+
if (this.options.webComponentPath) {
|
|
126
|
+
loaderList = [
|
|
127
|
+
...getRawCssLoaders,
|
|
128
|
+
...commonLoaderList,
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
loaderList = [
|
|
133
|
+
lastLoader,
|
|
134
|
+
...commonLoaderList,
|
|
135
|
+
];
|
|
136
|
+
}
|
|
96
137
|
module.loaders = (_c = (_b = (_a = this.options).overrideStylesheetLoaders) === null || _b === void 0 ? void 0 : _b.call(_a, loaderList)) !== null && _c !== void 0 ? _c : loaderList;
|
|
97
138
|
}
|
|
98
139
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semi-webpack-plugin.js","sourceRoot":"","sources":["../src/semi-webpack-plugin.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AAGxB,mCAAwC;
|
|
1
|
+
{"version":3,"file":"semi-webpack-plugin.js","sourceRoot":"","sources":["../src/semi-webpack-plugin.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AAGxB,mCAAwC;AA4BxC,MAAqB,iBAAiB;IAGlC,YAAY,OAAiC;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,QAAmC;;QACrC,IAAI,YAAY,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,cAAc,0CAAE,YAAY,CAAC;QAC7D,IAAI,CAAC,YAAY,IAAI,SAAS,IAAI,QAAQ;YAAE,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC;QACzF,8DAA8D;QAC9D,IAAI,CAAC,YAAY;YAAE,YAAY,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;QAEtE,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,WAAgB,EAAE,EAAE;YAC9D,IAAI,YAAY,CAAC,mBAAmB,EAAE;gBAClC,YAAY,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,OAAY,EAAE,MAAW,EAAE,EAAE;o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AC,OAAc;QAC7B,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACrF,CAAC;IAED,kBAAkB,CAAC,GAAqC;QACpD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,IAAI;YAC/C,OAAO,IAAI,GAAG,GAAG,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC;QAC7C,CAAC,EAAE,EAAE,CAAC,CAAC;IACX,CAAC;CACJ;AApKD,oCAoKC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-webpack-plugin",
|
|
3
|
-
"version": "2.59.0-
|
|
3
|
+
"version": "2.59.0-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "伍浩威 <wuhaowei.whw@bytedance.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"css-loader": "4.3.0",
|
|
25
25
|
"enhanced-resolve": "^5.8.3",
|
|
26
26
|
"loader-utils": "2.0.0",
|
|
27
|
+
"raw-loader": "^4.0.2",
|
|
27
28
|
"sass": "^1.54.9",
|
|
28
29
|
"sass-loader": "^10.1.1",
|
|
29
30
|
"semver": "7.3.2",
|
|
@@ -37,5 +38,5 @@
|
|
|
37
38
|
"rimraf": "^3.0.2",
|
|
38
39
|
"typescript": "^4"
|
|
39
40
|
},
|
|
40
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "cafc3d7cf008cd4fd117c3d55cc48e0b4430c4a9"
|
|
41
42
|
}
|