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 }
|
||||
) {
|
||||
const result = new ConcatSource(source);
|
||||
const exportsInfos = options.export
|
||||
const exportsInfo = options.export
|
||||
? [
|
||||
moduleGraph.getExportInfo(
|
||||
module,
|
||||
|
|
@ -151,7 +151,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|||
? "const"
|
||||
: "var";
|
||||
|
||||
for (const exportInfo of exportsInfos) {
|
||||
for (const exportInfo of exportsInfo) {
|
||||
if (!exportInfo.provided) continue;
|
||||
|
||||
let shouldContinue = false;
|
||||
|
|
@ -164,6 +164,7 @@ class ModuleLibraryPlugin extends AbstractLibraryPlugin {
|
|||
for (const reexportInfo of exp.orderedExports) {
|
||||
if (
|
||||
reexportInfo.provided === false &&
|
||||
reexportInfo.name !== "default" &&
|
||||
reexportInfo.name === /** @type {string[]} */ (reexport.export)[0]
|
||||
) {
|
||||
shouldContinue = true;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ module.exports = {
|
|||
output: {
|
||||
module: true,
|
||||
library: {
|
||||
type: "modern-module"
|
||||
type: "module"
|
||||
},
|
||||
filename: "[name].js",
|
||||
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 logo from './file.png';
|
||||
|
||||
export { value, T }
|
||||
type MyType = string;
|
||||
|
||||
export { logo, value, T, MyType }
|
||||
|
||||
it("should not reexport type", function () {
|
||||
expect(value).toBe(1)
|
||||
});
|
||||
|
||||
type OtherMyType = string;
|
||||
|
||||
export type { OtherMyType }
|
||||
export default MyType;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ module.exports = {
|
|||
output: {
|
||||
module: true,
|
||||
library: {
|
||||
type: "modern-module"
|
||||
type: "module"
|
||||
},
|
||||
chunkFormat: "module"
|
||||
},
|
||||
|
|
@ -35,7 +35,24 @@ module.exports = {
|
|||
options: {
|
||||
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