@rsbuild/plugin-svgr 2.0.0-alpha.3 → 2.0.0-rc.3

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.
@@ -1,20 +0,0 @@
1
- Copyright JS Foundation and other contributors
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- 'Software'), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1 +0,0 @@
1
- {"name":"url-loader","author":"Tobias Koppers @sokra","version":"4.1.1","funding":{"type":"opencollective","url":"https://opencollective.com/webpack"},"license":"MIT","types":"index.d.ts","type":"commonjs"}
package/dist/index.cjs DELETED
@@ -1,136 +0,0 @@
1
- "use strict";
2
- const __rslib_import_meta_url__ = "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
3
- var __webpack_require__ = {};
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module.default : ()=>module;
6
- return __webpack_require__.d(getter, {
7
- a: getter
8
- }), getter;
9
- }, __webpack_require__.d = (exports1, definition)=>{
10
- for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
11
- enumerable: !0,
12
- get: definition[key]
13
- });
14
- }, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
15
- "u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
16
- value: 'Module'
17
- }), Object.defineProperty(exports1, '__esModule', {
18
- value: !0
19
- });
20
- };
21
- var __webpack_exports__ = {};
22
- __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
23
- pluginSvgr: ()=>pluginSvgr,
24
- PLUGIN_SVGR_NAME: ()=>PLUGIN_SVGR_NAME
25
- });
26
- const external_node_path_namespaceObject = require("node:path");
27
- var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject);
28
- const external_node_url_namespaceObject = require("node:url"), plugin_react_namespaceObject = require("@rsbuild/plugin-react"), external_deepmerge_namespaceObject = require("deepmerge");
29
- var external_deepmerge_default = __webpack_require__.n(external_deepmerge_namespaceObject);
30
- const src_dirname = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__)), SVG_REGEX = /\.svg$/, getSvgoDefaultConfig = ()=>({
31
- plugins: [
32
- {
33
- name: 'preset-default',
34
- params: {
35
- overrides: {
36
- removeViewBox: !1
37
- }
38
- }
39
- },
40
- 'prefixIds'
41
- ]
42
- }), dedupeSvgoPlugins = (config)=>{
43
- if (!config.plugins) return config;
44
- let mergedPlugins = [];
45
- for (let plugin of config.plugins){
46
- if ('string' == typeof plugin) {
47
- mergedPlugins.find((item)=>item === plugin || 'object' == typeof item && item.name === plugin) || mergedPlugins.push(plugin);
48
- continue;
49
- }
50
- let strIndex = mergedPlugins.findIndex((item)=>'string' == typeof item && item === plugin.name);
51
- if (-1 !== strIndex) {
52
- mergedPlugins[strIndex] = plugin;
53
- continue;
54
- }
55
- let isMerged = !1;
56
- mergedPlugins = mergedPlugins.map((item)=>'object' == typeof item && item.name === plugin.name ? (isMerged = !0, external_deepmerge_default()(item, plugin)) : item), isMerged || mergedPlugins.push(plugin);
57
- }
58
- return config.plugins = mergedPlugins, config;
59
- }, PLUGIN_SVGR_NAME = 'rsbuild:svgr', pluginSvgr = (options = {})=>({
60
- name: PLUGIN_SVGR_NAME,
61
- pre: [
62
- plugin_react_namespaceObject.PLUGIN_REACT_NAME
63
- ],
64
- setup (api) {
65
- api.modifyBundlerChain((chain, { CHAIN_ID, environment })=>{
66
- let { config } = environment, { dataUriLimit } = config.output, maxSize = 'number' == typeof dataUriLimit ? dataUriLimit : dataUriLimit.svg, generatorOptions = {};
67
- chain.module.rules.has(CHAIN_ID.RULE.SVG) && (generatorOptions = chain.module.rules.get(CHAIN_ID.RULE.SVG).oneOfs.get(CHAIN_ID.ONE_OF.SVG_URL).get('generator'), chain.module.rules.delete(CHAIN_ID.RULE.SVG));
68
- let rule = chain.module.rule(CHAIN_ID.RULE.SVG).test(SVG_REGEX), svgrOptions = external_deepmerge_default()({
69
- svgo: !0,
70
- svgoConfig: getSvgoDefaultConfig()
71
- }, options.svgrOptions || {});
72
- svgrOptions.svgoConfig = dedupeSvgoPlugins(svgrOptions.svgoConfig), rule.oneOf(CHAIN_ID.ONE_OF.SVG_URL).type('asset/resource').resourceQuery(/^\?(__inline=false|url)$/).set('generator', generatorOptions), rule.oneOf(CHAIN_ID.ONE_OF.SVG_INLINE).type('asset/inline').resourceQuery(/^\?inline$/), CHAIN_ID.ONE_OF.SVG_RAW && rule.oneOf(CHAIN_ID.ONE_OF.SVG_RAW).type('asset/source').resourceQuery(/^\?raw$/), rule.oneOf(CHAIN_ID.ONE_OF.SVG_REACT).type("javascript/auto").resourceQuery(options.query || /react/).use(CHAIN_ID.USE.SVGR).loader(external_node_path_default().resolve(src_dirname, './loader.mjs')).options({
73
- ...svgrOptions,
74
- exportType: 'default'
75
- }).end();
76
- let { mixedImport = !1 } = options;
77
- if (mixedImport || svgrOptions.exportType) {
78
- let { exportType = mixedImport ? 'named' : void 0 } = svgrOptions, issuerInclude = [
79
- /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/,
80
- /\.mdx$/
81
- ], issuer = options.excludeImporter ? {
82
- and: [
83
- issuerInclude,
84
- {
85
- not: options.excludeImporter
86
- }
87
- ]
88
- } : issuerInclude, svgRule = rule.oneOf(CHAIN_ID.ONE_OF.SVG);
89
- options.exclude && svgRule.exclude.add(options.exclude), svgRule.type("javascript/auto").set('issuer', issuer).use(CHAIN_ID.USE.SVGR).loader(external_node_path_default().resolve(src_dirname, './loader.mjs')).options({
90
- ...svgrOptions,
91
- exportType
92
- }).end(), mixedImport && 'named' === exportType && svgRule.use(CHAIN_ID.USE.URL).loader(external_node_path_default().join(src_dirname, '../compiled', 'url-loader/index.js')).options({
93
- limit: maxSize,
94
- name: generatorOptions?.filename
95
- });
96
- }
97
- rule.oneOf(CHAIN_ID.ONE_OF.SVG_ASSET).type('asset').parser({
98
- dataUrlCondition: {
99
- maxSize
100
- }
101
- }).set('generator', generatorOptions);
102
- let jsRule = chain.module.rules.get(CHAIN_ID.RULE.JS).oneOfs.get(CHAIN_ID.ONE_OF.JS_MAIN);
103
- [
104
- CHAIN_ID.USE.SWC,
105
- CHAIN_ID.USE.BABEL
106
- ].some((jsUseId)=>{
107
- let use = jsRule.uses.get(jsUseId);
108
- if (!use) return !1;
109
- for (let oneOfId of [
110
- CHAIN_ID.ONE_OF.SVG,
111
- CHAIN_ID.ONE_OF.SVG_REACT
112
- ]){
113
- if (!rule.oneOfs.has(oneOfId)) continue;
114
- let loaderOptions = use.get('options');
115
- jsUseId === CHAIN_ID.USE.SWC && (loaderOptions = external_deepmerge_default()(loaderOptions, {
116
- jsc: {
117
- transform: {
118
- react: {
119
- refresh: !1
120
- }
121
- }
122
- }
123
- })), rule.oneOf(oneOfId).use(jsUseId).before(CHAIN_ID.USE.SVGR).loader(use.get('loader')).options(loaderOptions);
124
- }
125
- return !0;
126
- });
127
- });
128
- }
129
- });
130
- for(var __rspack_i in exports.PLUGIN_SVGR_NAME = __webpack_exports__.PLUGIN_SVGR_NAME, exports.pluginSvgr = __webpack_exports__.pluginSvgr, __webpack_exports__)-1 === [
131
- "PLUGIN_SVGR_NAME",
132
- "pluginSvgr"
133
- ].indexOf(__rspack_i) && (exports[__rspack_i] = __webpack_exports__[__rspack_i]);
134
- Object.defineProperty(exports, '__esModule', {
135
- value: !0
136
- });