@rsbuild/plugin-svgr 1.0.4 → 1.0.6

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/dist/loader.cjs DELETED
@@ -1,108 +0,0 @@
1
- "use strict";
2
- // The require scope
3
- var __webpack_require__ = {};
4
- /************************************************************************/ // webpack/runtime/compat_get_default_export
5
- (()=>{
6
- // getDefaultExport function for compatibility with non-harmony modules
7
- __webpack_require__.n = function(module) {
8
- var getter = module && module.__esModule ? function() {
9
- return module['default'];
10
- } : function() {
11
- return module;
12
- };
13
- __webpack_require__.d(getter, {
14
- a: getter
15
- });
16
- return getter;
17
- };
18
- })();
19
- // webpack/runtime/define_property_getters
20
- (()=>{
21
- __webpack_require__.d = function(exports1, definition) {
22
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
23
- enumerable: true,
24
- get: definition[key]
25
- });
26
- };
27
- })();
28
- // webpack/runtime/has_own_property
29
- (()=>{
30
- __webpack_require__.o = function(obj, prop) {
31
- return Object.prototype.hasOwnProperty.call(obj, prop);
32
- };
33
- })();
34
- // webpack/runtime/make_namespace_object
35
- (()=>{
36
- // define __esModule on exports
37
- __webpack_require__.r = function(exports1) {
38
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
39
- value: 'Module'
40
- });
41
- Object.defineProperty(exports1, '__esModule', {
42
- value: true
43
- });
44
- };
45
- })();
46
- /************************************************************************/ var __webpack_exports__ = {};
47
- // ESM COMPAT FLAG
48
- __webpack_require__.r(__webpack_exports__);
49
- // EXPORTS
50
- __webpack_require__.d(__webpack_exports__, {
51
- default: ()=>/* binding */ loader
52
- });
53
- const external_node_path_namespaceObject = require("node:path");
54
- const external_node_util_namespaceObject = require("node:util");
55
- const core_namespaceObject = require("@svgr/core");
56
- const plugin_jsx_namespaceObject = require("@svgr/plugin-jsx");
57
- var plugin_jsx_default = /*#__PURE__*/ __webpack_require__.n(plugin_jsx_namespaceObject);
58
- const plugin_svgo_namespaceObject = require("@svgr/plugin-svgo");
59
- var plugin_svgo_default = /*#__PURE__*/ __webpack_require__.n(plugin_svgo_namespaceObject);
60
- /**
61
- * Copyright (c) 2017, Smooth Code
62
- *
63
- * This source code is licensed under the MIT license found in the
64
- * LICENSE file in the root directory of this source tree.
65
- * modified from https://github.com/gregberge/svgr/blob/7595d378b73d4826a4cead165b3f32386b07315b/packages/webpack/src/index.ts
66
- */ const transformSvg = (0, external_node_util_namespaceObject.callbackify)(async (contents, config, state)=>(0, core_namespaceObject.transform)(contents, config, state));
67
- function svgrLoader(contents) {
68
- var _this;
69
- null === (_this = this) || void 0 === _this || _this.cacheable();
70
- const callback = this.async();
71
- const options = this.getOptions();
72
- const previousExport = (()=>{
73
- if (contents.startsWith('export ')) return contents;
74
- const exportMatches = contents.match(/^module.exports\s*=\s*(.*)/);
75
- return exportMatches ? `export default ${exportMatches[1]}` : null;
76
- })();
77
- const state = {
78
- caller: {
79
- name: '@rsbuild/plugin-svgr',
80
- previousExport,
81
- defaultPlugins: [
82
- plugin_svgo_default(),
83
- plugin_jsx_default()
84
- ]
85
- },
86
- filePath: (0, external_node_path_namespaceObject.normalize)(this.resourcePath)
87
- };
88
- if (previousExport) this.fs.readFile(this.resourcePath, (err, result)=>{
89
- if (err) {
90
- callback(err);
91
- return;
92
- }
93
- transformSvg(String(result), options, state, (err, content)=>{
94
- if (err) {
95
- callback(err);
96
- return;
97
- }
98
- callback(null, content);
99
- });
100
- });
101
- else transformSvg(contents, options, state, callback);
102
- }
103
- /* harmony default export */ const loader = svgrLoader;
104
- var __webpack_export_target__ = exports;
105
- for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
106
- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
107
- value: true
108
- });