简体   繁体   English

使用webpack从条目中导出(函数)

[英]Export (a function) from the entry, using webpack

I would like to export from the entry : 我想从entry导出:

C.js : C.js

export default class C { static get foo() { return "foo"; } }

entry.js : entry.js

import C from "./C";
export default function callMe(a) { return a + C.foo; }

This (using libraryTarget: "amd" ) would result in something like (simplified) (使用libraryTarget: "amd" )将导致类似(简化)的操作

output.js : output.js

define("entry", ["./C"], function(C) { return function(a) { return a + C.foo; }; })

However, when webpack ing the entry , I get an output that just exports {} , even though it correctly contains callMe . 但是,在对entry webpack时,即使正确包含callMe ,我webpack得到仅导出{}的输出。

解决方案是使用libraryTarget: "umd"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM