Typescript 如何在rollup.js中将默认和命名的外部导入都指定为output.globals?
我找不到如何使用rollup.js(v1.27.0)将默认导入和命名导入都指定为output.globals 我在html文件中使用apprun.js作为外部文件 My index.html:Typescript 如何在rollup.js中将默认和命名的外部导入都指定为output.globals?,typescript,rollupjs,Typescript,Rollupjs,我找不到如何使用rollup.js(v1.27.0)将默认导入和命名导入都指定为output.globals 我在html文件中使用apprun.js作为外部文件 My index.html: <!doctype html> <html> <head> <script src="https://unpkg.com/apprun@1.22.2/dist/apprun.js"></script> </head> <body
<!doctype html>
<html>
<head>
<script src="https://unpkg.com/apprun@1.22.2/dist/apprun.js"></script>
</head>
<body>
<script src="x.js"></script>
</body>
</html>
rollup-c-w给出了x.js
var Page = /** @class */ (function (_super) {
__extends(Page, _super);
function Page() {
...
return _this;
}
return Page;
}(app.Component)); // <<--- app.Component is undefined, should be Component
app__default.render(document.body, app__default.createElement(Page, null));
}(app));
var Page=/**@class*/(函数(_super){
__扩展(第页,超级);
功能页(){
...
把这个还给你;
}
返回页面;
}(应用程序组件));//碰巧你找到了答案吗?不幸的是没有。我已经离开了。
import typescript from 'rollup-plugin-typescript'
import { terser } from 'rollup-plugin-terser'
const production = !process.env.ROLLUP_WATCH
export default {
external: ['apprun']
, input: 'x.tsx'
, output: {
file: 'x.js'
, format: 'iife'
, globals: {
apprun: 'app' // <<-- how to add 'Component' also?
}
}
, plugins: [
typescript()
, production && terser()
]
}
var Page = /** @class */ (function (_super) {
__extends(Page, _super);
function Page() {
...
return _this;
}
return Page;
}(app.Component)); // <<--- app.Component is undefined, should be Component
app__default.render(document.body, app__default.createElement(Page, null));
}(app));