Skip to content

Commit c3dca47

Browse files
committed
fix(loader): remove handling a non-existent case
1 parent 3401dca commit c3dca47

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/loader.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const MiniCssExtractPlugin = require("./index");
2323
/** @typedef {import("webpack").AssetInfo} AssetInfo */
2424
/** @typedef {import("webpack").NormalModule} NormalModule */
2525
/** @typedef {import("./index.js").LoaderOptions} LoaderOptions */
26-
/** @typedef {{ [key: string]: string | function } | function} Locals */
26+
/** @typedef {{ [key: string]: string | function }} Locals */
2727

2828
/** @typedef {any} TODO */
2929

@@ -172,8 +172,7 @@ function pitch(request) {
172172
locals = {};
173173
}
174174

175-
/** @type {{ [key: string]: string }} */ (locals)[key] =
176-
originalExports[key];
175+
/** @type {Locals} */ (locals)[key] = originalExports[key];
177176
}
178177
});
179178
} else {
@@ -232,15 +231,13 @@ function pitch(request) {
232231
.map(
233232
(key) =>
234233
`\nexport var ${key} = ${stringifyLocal(
235-
/** @type {{ [key: string]: string | function }} */ (locals)[
236-
key
237-
]
234+
/** @type {Locals} */ (locals)[key]
238235
)};`
239236
)
240237
.join("")
241238
: `\n${
242239
esModule ? "export default" : "module.exports ="
243-
} ${stringifyLocal(/** @type {function} */ (locals))};`
240+
} ${JSON.stringify(locals)};`
244241
: esModule
245242
? `\nexport {};`
246243
: "";

test/stringifyLocal.test.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
import { stringifyLocal } from "../src/utils";
22

33
describe("stringifyLocal", () => {
4-
it(`object`, async () => {
5-
const testObj = { classNameA: "classA", classNameB: "classB" };
6-
const actual = stringifyLocal(testObj);
7-
8-
expect(
9-
actual === '{"classNameA":"classA","classNameB":"classB"}' ||
10-
actual === '{"classNameB":"classB","classNameA":"classA"}'
11-
).toBe(true);
12-
});
13-
144
it(`primitive`, async () => {
155
const testObj = "classA";
166

0 commit comments

Comments
 (0)