Skip to content

Commit acf5722

Browse files
test: add test for new URL(...) (#829)
1 parent cd23644 commit acf5722

File tree

7 files changed

+133
-0
lines changed

7 files changed

+133
-0
lines changed
Loading

test/cases/new-url/expected/main.css

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
body {
2+
background: red;
3+
}
4+
5+
a {
6+
background: url(09a1a1112c577c279435.png);
7+
}
8+

test/cases/new-url/expected/main.js

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/******/ (() => { // webpackBootstrap
2+
/******/ var __webpack_modules__ = ([
3+
/* 0 */,
4+
/* 1 */
5+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6+
7+
"use strict";
8+
__webpack_require__.r(__webpack_exports__);
9+
// extracted by mini-css-extract-plugin
10+
11+
12+
/***/ })
13+
/******/ ]);
14+
/************************************************************************/
15+
/******/ // The module cache
16+
/******/ var __webpack_module_cache__ = {};
17+
/******/
18+
/******/ // The require function
19+
/******/ function __webpack_require__(moduleId) {
20+
/******/ // Check if module is in cache
21+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
22+
/******/ if (cachedModule !== undefined) {
23+
/******/ return cachedModule.exports;
24+
/******/ }
25+
/******/ // Create a new module (and put it into the cache)
26+
/******/ var module = __webpack_module_cache__[moduleId] = {
27+
/******/ // no module.id needed
28+
/******/ // no module.loaded needed
29+
/******/ exports: {}
30+
/******/ };
31+
/******/
32+
/******/ // Execute the module function
33+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
34+
/******/
35+
/******/ // Return the exports of the module
36+
/******/ return module.exports;
37+
/******/ }
38+
/******/
39+
/******/ // expose the modules object (__webpack_modules__)
40+
/******/ __webpack_require__.m = __webpack_modules__;
41+
/******/
42+
/************************************************************************/
43+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
44+
/******/ (() => {
45+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
46+
/******/ })();
47+
/******/
48+
/******/ /* webpack/runtime/make namespace object */
49+
/******/ (() => {
50+
/******/ // define __esModule on exports
51+
/******/ __webpack_require__.r = (exports) => {
52+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
53+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
54+
/******/ }
55+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
56+
/******/ };
57+
/******/ })();
58+
/******/
59+
/******/ /* webpack/runtime/jsonp chunk loading */
60+
/******/ (() => {
61+
/******/ __webpack_require__.b = document.baseURI || self.location.href;
62+
/******/
63+
/******/ // object to store loaded and loading chunks
64+
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
65+
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
66+
/******/ var installedChunks = {
67+
/******/ 0: 0
68+
/******/ };
69+
/******/
70+
/******/ // no chunk on demand loading
71+
/******/
72+
/******/ // no prefetching
73+
/******/
74+
/******/ // no preloaded
75+
/******/
76+
/******/ // no HMR
77+
/******/
78+
/******/ // no HMR manifest
79+
/******/
80+
/******/ // no on chunks loaded
81+
/******/
82+
/******/ // no jsonp function
83+
/******/ })();
84+
/******/
85+
/************************************************************************/
86+
var __webpack_exports__ = {};
87+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
88+
(() => {
89+
const myURL = new URL(/* asset import */ __webpack_require__(1), __webpack_require__.b);
90+
91+
console.log(myURL);
92+
93+
})();
94+
95+
/******/ })()
96+
;

test/cases/new-url/img.png

76.3 KB
Loading

test/cases/new-url/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const myURL = new URL("./style.css", import.meta.url);
2+
3+
console.log(myURL);

test/cases/new-url/style.css

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
body {
2+
background: red;
3+
}
4+
5+
a {
6+
background: url("./img.png");
7+
}

test/cases/new-url/webpack.config.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Self from "../../../src";
2+
3+
module.exports = {
4+
entry: "./index.js",
5+
module: {
6+
rules: [
7+
{
8+
test: /\.css$/,
9+
use: [Self.loader, "css-loader"],
10+
type: "javascript/auto",
11+
},
12+
],
13+
},
14+
plugins: [
15+
new Self({
16+
filename: "[name].css",
17+
}),
18+
],
19+
};

0 commit comments

Comments
 (0)