@@ -41,39 +41,8 @@ test('set the size threshold to inline static assets', async () => {
4141 "
4242 ` ) ;
4343 expect ( logoJs2 ) . toMatchInlineSnapshot ( `
44- "var __webpack_modules__ = {
45- "./src/assets/logo.svg?__rslib_entry__": function(module, __unused_webpack_exports, __webpack_require__) {
46- module.exports = require('../static/svg/logo.svg');
47- }
48- };
49- var __webpack_module_cache__ = {};
50- function __webpack_require__(moduleId) {
51- var cachedModule = __webpack_module_cache__[moduleId];
52- if (void 0 !== cachedModule) return cachedModule.exports;
53- var module = __webpack_module_cache__[moduleId] = {
54- exports: {}
55- };
56- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
57- return module.exports;
58- }
59- (()=>{
60- __webpack_require__.g = function() {
61- if ('object' == typeof globalThis) return globalThis;
62- try {
63- return this || new Function('return this')();
64- } catch (e) {
65- if ('object' == typeof window) return window;
66- }
67- }();
68- })();
69- (()=>{
70- var scriptUrl;
71- if ("string" == typeof import.meta.url) scriptUrl = import.meta.url;
72- if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
73- scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\\?.*$/, "").replace(/\\/[^\\/]+$/, "/");
74- __webpack_require__.p = scriptUrl + '../';
75- })();
76- __webpack_require__("./src/assets/logo.svg?__rslib_entry__");
44+ "import __rslib_asset__ from '../static/svg/logo.svg';
45+ export default __rslib_asset__;
7746 "
7847 ` ) ;
7948 // cjs
@@ -86,56 +55,7 @@ test('set the size threshold to inline static assets', async () => {
8655 'const logo_cjs_namespaceObject = require("./assets/logo.cjs");' ,
8756 ) ;
8857 expect ( logoCjs2 ) . toMatchInlineSnapshot ( `
89- ""use strict";
90- var __webpack_modules__ = {
91- "./src/assets/logo.svg?__rslib_entry__": function(module, __unused_webpack_exports, __webpack_require__) {
92- module.exports = require('../static/svg/logo.svg');
93- }
94- };
95- var __webpack_module_cache__ = {};
96- function __webpack_require__(moduleId) {
97- var cachedModule = __webpack_module_cache__[moduleId];
98- if (void 0 !== cachedModule) return cachedModule.exports;
99- var module = __webpack_module_cache__[moduleId] = {
100- exports: {}
101- };
102- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
103- return module.exports;
104- }
105- (()=>{
106- __webpack_require__.g = function() {
107- if ('object' == typeof globalThis) return globalThis;
108- try {
109- return this || new Function('return this')();
110- } catch (e) {
111- if ('object' == typeof window) return window;
112- }
113- }();
114- })();
115- (()=>{
116- var scriptUrl;
117- if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
118- var document = __webpack_require__.g.document;
119- if (!scriptUrl && document) {
120- if (document.currentScript && 'SCRIPT' === document.currentScript.tagName.toUpperCase()) scriptUrl = document.currentScript.src;
121- if (!scriptUrl) {
122- var scripts = document.getElementsByTagName("script");
123- if (scripts.length) {
124- var i = scripts.length - 1;
125- while(i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl)))scriptUrl = scripts[i--].src;
126- }
127- }
128- }
129- if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
130- scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\\?.*$/, "").replace(/\\/[^\\/]+$/, "/");
131- __webpack_require__.p = scriptUrl + '../';
132- })();
133- var __webpack_exports__ = __webpack_require__("./src/assets/logo.svg?__rslib_entry__");
134- var __webpack_export_target__ = exports;
135- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
136- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
137- value: true
138- });
58+ "module.exports = require('../static/svg/logo.svg');
13959 "
14060 ` ) ;
14161} ) ;
@@ -162,39 +82,8 @@ test('set the assets filename with hash', async () => {
16282 / a s s e t s \/ i m a g e \. j s / ,
16383 ) ;
16484 expect ( imageJs1 ) . toMatchInlineSnapshot ( `
165- "var __webpack_modules__ = {
166- "./src/assets/image.png?__rslib_entry__": function(module, __unused_webpack_exports, __webpack_require__) {
167- module.exports = require('../static/image/image.c74653c1712618b1.png');
168- }
169- };
170- var __webpack_module_cache__ = {};
171- function __webpack_require__(moduleId) {
172- var cachedModule = __webpack_module_cache__[moduleId];
173- if (void 0 !== cachedModule) return cachedModule.exports;
174- var module = __webpack_module_cache__[moduleId] = {
175- exports: {}
176- };
177- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
178- return module.exports;
179- }
180- (()=>{
181- __webpack_require__.g = function() {
182- if ('object' == typeof globalThis) return globalThis;
183- try {
184- return this || new Function('return this')();
185- } catch (e) {
186- if ('object' == typeof window) return window;
187- }
188- }();
189- })();
190- (()=>{
191- var scriptUrl;
192- if ("string" == typeof import.meta.url) scriptUrl = import.meta.url;
193- if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
194- scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\\?.*$/, "").replace(/\\/[^\\/]+$/, "/");
195- __webpack_require__.p = scriptUrl + '../';
196- })();
197- __webpack_require__("./src/assets/image.png?__rslib_entry__");
85+ "import __rslib_asset__ from '../static/image/image.c74653c1712618b1.png';
86+ export default __rslib_asset__;
19887 "
19988 ` ) ;
20089 // cjs
@@ -203,56 +92,7 @@ test('set the assets filename with hash', async () => {
20392 / a s s e t s \/ i m a g e \. c j s / ,
20493 ) ;
20594 expect ( imageCjs1 ) . toMatchInlineSnapshot ( `
206- ""use strict";
207- var __webpack_modules__ = {
208- "./src/assets/image.png?__rslib_entry__": function(module, __unused_webpack_exports, __webpack_require__) {
209- module.exports = require('../static/image/image.c74653c1712618b1.png');
210- }
211- };
212- var __webpack_module_cache__ = {};
213- function __webpack_require__(moduleId) {
214- var cachedModule = __webpack_module_cache__[moduleId];
215- if (void 0 !== cachedModule) return cachedModule.exports;
216- var module = __webpack_module_cache__[moduleId] = {
217- exports: {}
218- };
219- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
220- return module.exports;
221- }
222- (()=>{
223- __webpack_require__.g = function() {
224- if ('object' == typeof globalThis) return globalThis;
225- try {
226- return this || new Function('return this')();
227- } catch (e) {
228- if ('object' == typeof window) return window;
229- }
230- }();
231- })();
232- (()=>{
233- var scriptUrl;
234- if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
235- var document = __webpack_require__.g.document;
236- if (!scriptUrl && document) {
237- if (document.currentScript && 'SCRIPT' === document.currentScript.tagName.toUpperCase()) scriptUrl = document.currentScript.src;
238- if (!scriptUrl) {
239- var scripts = document.getElementsByTagName("script");
240- if (scripts.length) {
241- var i = scripts.length - 1;
242- while(i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl)))scriptUrl = scripts[i--].src;
243- }
244- }
245- }
246- if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
247- scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\\?.*$/, "").replace(/\\/[^\\/]+$/, "/");
248- __webpack_require__.p = scriptUrl + '../';
249- })();
250- var __webpack_exports__ = __webpack_require__("./src/assets/image.png?__rslib_entry__");
251- var __webpack_export_target__ = exports;
252- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
253- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
254- value: true
255- });
95+ "module.exports = require('../static/image/image.c74653c1712618b1.png');
25696 "
25797 ` ) ;
25898} ) ;
@@ -279,39 +119,8 @@ test('set the assets output path', async () => {
279119 / a s s e t s \/ i m a g e \. j s / ,
280120 ) ;
281121 expect ( imageJs1 ) . toMatchInlineSnapshot ( `
282- "var __webpack_modules__ = {
283- "./src/assets/image.png?__rslib_entry__": function(module, __unused_webpack_exports, __webpack_require__) {
284- module.exports = require('../assets/bundleless/image.png');
285- }
286- };
287- var __webpack_module_cache__ = {};
288- function __webpack_require__(moduleId) {
289- var cachedModule = __webpack_module_cache__[moduleId];
290- if (void 0 !== cachedModule) return cachedModule.exports;
291- var module = __webpack_module_cache__[moduleId] = {
292- exports: {}
293- };
294- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
295- return module.exports;
296- }
297- (()=>{
298- __webpack_require__.g = function() {
299- if ('object' == typeof globalThis) return globalThis;
300- try {
301- return this || new Function('return this')();
302- } catch (e) {
303- if ('object' == typeof window) return window;
304- }
305- }();
306- })();
307- (()=>{
308- var scriptUrl;
309- if ("string" == typeof import.meta.url) scriptUrl = import.meta.url;
310- if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
311- scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\\?.*$/, "").replace(/\\/[^\\/]+$/, "/");
312- __webpack_require__.p = scriptUrl + '../';
313- })();
314- __webpack_require__("./src/assets/image.png?__rslib_entry__");
122+ "import __rslib_asset__ from '../assets/bundleless/image.png';
123+ export default __rslib_asset__;
315124 "
316125 ` ) ;
317126 // cjs
@@ -320,56 +129,7 @@ test('set the assets output path', async () => {
320129 / a s s e t s \/ i m a g e \. c j s / ,
321130 ) ;
322131 expect ( imageCjs1 ) . toMatchInlineSnapshot ( `
323- ""use strict";
324- var __webpack_modules__ = {
325- "./src/assets/image.png?__rslib_entry__": function(module, __unused_webpack_exports, __webpack_require__) {
326- module.exports = require('../assets/bundleless/image.png');
327- }
328- };
329- var __webpack_module_cache__ = {};
330- function __webpack_require__(moduleId) {
331- var cachedModule = __webpack_module_cache__[moduleId];
332- if (void 0 !== cachedModule) return cachedModule.exports;
333- var module = __webpack_module_cache__[moduleId] = {
334- exports: {}
335- };
336- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
337- return module.exports;
338- }
339- (()=>{
340- __webpack_require__.g = function() {
341- if ('object' == typeof globalThis) return globalThis;
342- try {
343- return this || new Function('return this')();
344- } catch (e) {
345- if ('object' == typeof window) return window;
346- }
347- }();
348- })();
349- (()=>{
350- var scriptUrl;
351- if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
352- var document = __webpack_require__.g.document;
353- if (!scriptUrl && document) {
354- if (document.currentScript && 'SCRIPT' === document.currentScript.tagName.toUpperCase()) scriptUrl = document.currentScript.src;
355- if (!scriptUrl) {
356- var scripts = document.getElementsByTagName("script");
357- if (scripts.length) {
358- var i = scripts.length - 1;
359- while(i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl)))scriptUrl = scripts[i--].src;
360- }
361- }
362- }
363- if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
364- scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\\?.*$/, "").replace(/\\/[^\\/]+$/, "/");
365- __webpack_require__.p = scriptUrl + '../';
366- })();
367- var __webpack_exports__ = __webpack_require__("./src/assets/image.png?__rslib_entry__");
368- var __webpack_export_target__ = exports;
369- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
370- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
371- value: true
372- });
132+ "module.exports = require('../assets/bundleless/image.png');
373133 "
374134 ` ) ;
375135} ) ;
0 commit comments