mirror of https://github.com/webpack/webpack.git
test: refactor to new API
This commit is contained in:
parent
386201511c
commit
ff3eedd575
|
@ -76,7 +76,6 @@
|
||||||
"less": "^4.0.0",
|
"less": "^4.0.0",
|
||||||
"less-loader": "^8.0.0",
|
"less-loader": "^8.0.0",
|
||||||
"lint-staged": "^13.2.1",
|
"lint-staged": "^13.2.1",
|
||||||
"loader-utils": "^2.0.3",
|
|
||||||
"lodash": "^4.17.19",
|
"lodash": "^4.17.19",
|
||||||
"lodash-es": "^4.17.15",
|
"lodash-es": "^4.17.15",
|
||||||
"memfs": "^3.5.0",
|
"memfs": "^3.5.0",
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
const { getRemainingRequest, stringifyRequest } = require("loader-utils");
|
|
||||||
|
|
||||||
const loaderPath = require.resolve("./loader");
|
const loaderPath = require.resolve("./loader");
|
||||||
|
|
||||||
/** @type {import("../../../../").LoaderDefinition} */
|
/** @type {import("../../../../").LoaderDefinition} */
|
||||||
|
@ -12,12 +10,10 @@ export default answer;
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const matchResource = `${this.resourcePath}.js`;
|
const matchResource = `${this.utils.contextify(this.context, this.resourcePath)}.js`;
|
||||||
const loader = `${loaderPath}?load`;
|
const loader = `${this.utils.contextify(this.context, loaderPath)}?load`;
|
||||||
const remaining = getRemainingRequest(this);
|
const remaining = this.utils.contextify(this.context, this.remainingRequest);
|
||||||
const request = JSON.parse(
|
const request = `${matchResource}!=!${loader}!${remaining}`;
|
||||||
stringifyRequest(this, `${matchResource}!=!${loader}!${remaining}`)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.async();
|
this.async();
|
||||||
this.loadModule(request, (err, source) => {
|
this.loadModule(request, (err, source) => {
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
const stringifyRequest = require("loader-utils").stringifyRequest;
|
|
||||||
|
|
||||||
/** @type {import("../../../../").PitchLoaderDefinitionFunction} */
|
/** @type {import("../../../../").PitchLoaderDefinitionFunction} */
|
||||||
module.exports.pitch = function (remainingRequest) {
|
module.exports.pitch = function (remainingRequest) {
|
||||||
return `
|
return `
|
||||||
import { getString as _getString, memory } from ${stringifyRequest(
|
import { getString as _getString, memory } from ${
|
||||||
this,
|
JSON.stringify(`${this.utils.contextify(this.context, this.resourcePath)}.wat!=!${this.utils.contextify(this.context, remainingRequest)}`)
|
||||||
`${this.resourcePath}.wat!=!${remainingRequest}`
|
};
|
||||||
)};
|
|
||||||
|
|
||||||
export function getString() {
|
export function getString() {
|
||||||
const strBuf = new Uint8Array(memory.buffer, _getString());
|
const strBuf = new Uint8Array(memory.buffer, _getString());
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
const stringifyRequest = require("loader-utils").stringifyRequest;
|
|
||||||
|
|
||||||
/** @type {import("../../../../").PitchLoaderDefinitionFunction} */
|
/** @type {import("../../../../").PitchLoaderDefinitionFunction} */
|
||||||
module.exports.pitch = function (remainingRequest) {
|
module.exports.pitch = function (remainingRequest) {
|
||||||
return `
|
return `
|
||||||
import { getString as _getString, memory } from ${stringifyRequest(
|
import { getString as _getString, memory } from ${
|
||||||
this,
|
JSON.stringify(`${this.utils.contextify(this.context, this.resourcePath)}.wat!=!${this.utils.contextify(this.context, remainingRequest)}`)
|
||||||
`${this.resourcePath}.wasm!=!wast-loader!${remainingRequest}`
|
};
|
||||||
)};
|
|
||||||
|
|
||||||
export function getString() {
|
export function getString() {
|
||||||
const strBuf = new Uint8Array(memory.buffer, _getString());
|
const strBuf = new Uint8Array(memory.buffer, _getString());
|
||||||
|
|
|
@ -4331,7 +4331,7 @@ loader-utils@^1.1.0:
|
||||||
emojis-list "^3.0.0"
|
emojis-list "^3.0.0"
|
||||||
json5 "^1.0.1"
|
json5 "^1.0.1"
|
||||||
|
|
||||||
loader-utils@^2.0.0, loader-utils@^2.0.3:
|
loader-utils@^2.0.0:
|
||||||
version "2.0.4"
|
version "2.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.4.tgz#8b5cb38b5c34a9a018ee1fc0e6a066d1dfcc528c"
|
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.4.tgz#8b5cb38b5c34a9a018ee1fc0e6a066d1dfcc528c"
|
||||||
integrity sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==
|
integrity sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==
|
||||||
|
|
Loading…
Reference in New Issue