[英]Expose legacy revealing module pattern methods and variables using Webpack
I'm trying to hotwire webpack to use some legacy code but this arrangement:我正在尝试热线 webpack 使用一些遗留代码,但这种安排:
slidesystem.js:幻灯片系统.js:
export var slideSystem = (function () {
var position = 0;
function init() {
alert('winner!');
} // init
})();
app.js应用程序.js
import {slideSystem} from './slidesystem';
slideSystem.init();
alert(slideSystem.position);
Isn't working as expected... Is there a better way to do this?没有按预期工作......有没有更好的方法来做到这一点?
Here's one way to do it using the demo above:这是使用上面的演示来做到这一点的一种方法:
slidesystem.js幻灯片系统.js
const slideSystem = (function () {
'use strict';
var position = 0;
function init() {
alert('winner!');
} // init
return {
init: init,
pos: pos
};
})();
export default slideSystem;
app.js应用程序.js
import {slideSystem} from './slidesystem';
slideSystem.init();
alert(slideSystem.position);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.