-
-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support nmf resolve hook (#6998)
- Loading branch information
Showing
17 changed files
with
351 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/hookCases/normalModuleFactory#resolve/resource/a.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = "a"; |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/hookCases/normalModuleFactory#resolve/resource/b.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = "b"; |
1 change: 1 addition & 0 deletions
1
packages/rspack-test-tools/tests/hookCases/normalModuleFactory#resolve/resource/c.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = "c"; |
104 changes: 104 additions & 0 deletions
104
...es/rspack-test-tools/tests/hookCases/normalModuleFactory#resolve/resource/output.snap.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
```js title=main.js | ||
(() => { // webpackBootstrap | ||
var __webpack_modules__ = ({ | ||
"./a.js": (function (module) { | ||
module.exports = "a"; | ||
|
||
|
||
}), | ||
"./b.js": (function (module) { | ||
module.exports = "c"; | ||
|
||
|
||
}), | ||
|
||
}); | ||
/************************************************************************/ | ||
// The module cache | ||
var __webpack_module_cache__ = {}; | ||
|
||
// The require function | ||
function __webpack_require__(moduleId) { | ||
|
||
// Check if module is in cache | ||
var cachedModule = __webpack_module_cache__[moduleId]; | ||
if (cachedModule !== undefined) { | ||
return cachedModule.exports; | ||
} | ||
// Create a new module (and put it into the cache) | ||
var module = (__webpack_module_cache__[moduleId] = { | ||
exports: {} | ||
}); | ||
// Execute the module function | ||
__webpack_modules__[moduleId](module, module.exports, __webpack_require__); | ||
|
||
// Return the exports of the module | ||
return module.exports; | ||
|
||
} | ||
|
||
/************************************************************************/ | ||
// webpack/runtime/compat_get_default_export | ||
(() => { | ||
// getDefaultExport function for compatibility with non-harmony modules | ||
__webpack_require__.n = function (module) { | ||
var getter = module && module.__esModule ? | ||
function () { return module['default']; } : | ||
function () { return module; }; | ||
__webpack_require__.d(getter, { a: getter }); | ||
return getter; | ||
}; | ||
|
||
|
||
|
||
|
||
})(); | ||
// webpack/runtime/define_property_getters | ||
(() => { | ||
__webpack_require__.d = function(exports, definition) { | ||
for(var key in definition) { | ||
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | ||
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | ||
} | ||
} | ||
}; | ||
})(); | ||
// webpack/runtime/has_own_property | ||
(() => { | ||
__webpack_require__.o = function (obj, prop) { | ||
return Object.prototype.hasOwnProperty.call(obj, prop); | ||
}; | ||
|
||
})(); | ||
/************************************************************************/ | ||
var __webpack_exports__ = {}; | ||
// This entry need to be wrapped in an IIFE because it need to be in strict mode. | ||
(() => { | ||
"use strict"; | ||
|
||
// EXTERNAL MODULE: ./a.js | ||
let a_ = __webpack_require__("./a.js"); | ||
let a_default = /*#__PURE__*/__webpack_require__.n(a_); | ||
// EXTERNAL MODULE: ./b.js | ||
let b_ = __webpack_require__("./b.js"); | ||
let b_default = /*#__PURE__*/__webpack_require__.n(b_); | ||
;// CONCATENATED MODULE: external "fs" | ||
var external_fs_namespaceObject = require("fs"); | ||
let external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_namespaceObject); | ||
;// CONCATENATED MODULE: ./resource.js | ||
|
||
|
||
|
||
|
||
it("should modify resource by resolve hook", () => { | ||
expect((a_default())).toBe("a"); | ||
expect((b_default())).toBe("c"); | ||
const ext = ".js"; | ||
expect(external_fs_default().readFileSync(__filename, "utf-8")).toContain("./b" + ext); | ||
}); | ||
|
||
})(); | ||
|
||
})() | ||
; | ||
``` |
10 changes: 10 additions & 0 deletions
10
packages/rspack-test-tools/tests/hookCases/normalModuleFactory#resolve/resource/resource.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import a from "./a"; | ||
import b from "./b"; | ||
import fs from "fs"; | ||
|
||
it("should modify resource by resolve hook", () => { | ||
expect(a).toBe("a"); | ||
expect(b).toBe("c"); | ||
const ext = ".js"; | ||
expect(fs.readFileSync(__filename, "utf-8")).toContain("./b" + ext); | ||
}); |
Oops, something went wrong.
6fa3fd7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Ran ecosystem CI: Open
6fa3fd7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 Benchmark detail: Open