mirror of https://github.com/webpack/webpack.git
fix: don't skip export generation for default reexport (#19463)
This commit is contained in:
parent
648e026c1e
commit
dc33a1e662
|
|
@ -124,7 +124,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
||||||
{ options, compilation }
|
{ options, compilation }
|
||||||
) {
|
) {
|
||||||
const result = new ConcatSource(source);
|
const result = new ConcatSource(source);
|
||||||
const exportsInfos = options.export
|
const exportsInfo = options.export
|
||||||
? [
|
? [
|
||||||
moduleGraph.getExportInfo(
|
moduleGraph.getExportInfo(
|
||||||
module,
|
module,
|
||||||
|
|
@ -151,7 +151,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
||||||
? "const"
|
? "const"
|
||||||
: "var";
|
: "var";
|
||||||
|
|
||||||
for (const exportInfo of exportsInfos) {
|
for (const exportInfo of exportsInfo) {
|
||||||
if (!exportInfo.provided) continue;
|
if (!exportInfo.provided) continue;
|
||||||
|
|
||||||
let shouldContinue = false;
|
let shouldContinue = false;
|
||||||
|
|
@ -164,6 +164,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
||||||
for (const reexportInfo of exp.orderedExports) {
|
for (const reexportInfo of exp.orderedExports) {
|
||||||
if (
|
if (
|
||||||
reexportInfo.provided === false &&
|
reexportInfo.provided === false &&
|
||||||
|
reexportInfo.name !== "default" &&
|
||||||
reexportInfo.name === /** @type {string[]} */ (reexport.export)[0]
|
reexportInfo.name === /** @type {string[]} */ (reexport.export)[0]
|
||||||
) {
|
) {
|
||||||
shouldContinue = true;
|
shouldContinue = true;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ module.exports = {
|
||||||
output: {
|
output: {
|
||||||
module: true,
|
module: true,
|
||||||
library: {
|
library: {
|
||||||
type: "modern-module"
|
type: "module"
|
||||||
},
|
},
|
||||||
filename: "[name].js",
|
filename: "[name].js",
|
||||||
chunkFormat: "module"
|
chunkFormat: "module"
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
|
|
@ -0,0 +1,4 @@
|
||||||
|
declare module "*.png" {
|
||||||
|
const value: string;
|
||||||
|
export default value;
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,15 @@
|
||||||
import { value, T } from './re-export'
|
import { value, T } from './re-export'
|
||||||
|
import logo from './file.png';
|
||||||
|
|
||||||
export { value, T }
|
type MyType = string;
|
||||||
|
|
||||||
|
export { logo, value, T, MyType }
|
||||||
|
|
||||||
it("should not reexport type", function () {
|
it("should not reexport type", function () {
|
||||||
expect(value).toBe(1)
|
expect(value).toBe(1)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
type OtherMyType = string;
|
||||||
|
|
||||||
|
export type { OtherMyType }
|
||||||
|
export default MyType;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ module.exports = {
|
||||||
output: {
|
output: {
|
||||||
module: true,
|
module: true,
|
||||||
library: {
|
library: {
|
||||||
type: "modern-module"
|
type: "module"
|
||||||
},
|
},
|
||||||
chunkFormat: "module"
|
chunkFormat: "module"
|
||||||
},
|
},
|
||||||
|
|
@ -35,7 +35,24 @@ module.exports = {
|
||||||
options: {
|
options: {
|
||||||
transpileOnly: true
|
transpileOnly: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "asset/inline",
|
||||||
|
test: /\.png$/
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
function () {
|
||||||
|
const handler = compilation => {
|
||||||
|
compilation.hooks.afterProcessAssets.tap("testcase", assets => {
|
||||||
|
const source = assets["bundle0.mjs"].source();
|
||||||
|
expect(source).toContain(
|
||||||
|
"export { file_namespaceObject as logo, value };"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
this.hooks.compilation.tap("testcase", handler);
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue