我正在使用aws-iot-device-sdk库进行websocket连接,并将它们全部与汇总捆绑在一起。 我有以下配置:
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import builtins from 'rollup-plugin-node-builtins';
import uglify from 'rollup-plugin-uglify';
import commonjs from 'rollup-plugin-commonjs';
import async from 'rollup-plugin-async';
import json from 'rollup-plugin-json';
import replace from 'rollup-plugin-replace';
import globals from 'rollup-plugin-node-globals';
import { minify } from 'uglify-es';
const pkg = require('./package.json');
export default {
name: 'InPlayer',
input: 'src/index.js',
output: [
{
file: pkg.browser,
format: 'umd',
},
{
file: 'examples/js/inplayer.js',
format: 'umd',
},
],
plugins: [
builtins(),
async(),
replace({
ENVIRONMENT: JSON.stringify('production'),
}),
babel({
exclude: ['node_modules/**'],
}),
resolve({
browser: true,
jsnext: true,
}),
commonjs({
include: 'node_modules/**',
namedExports: {
'node_modules/aws-iot-device-sdk/index.js': ['aws-iot-device-sdk'],
}
}),
uglify({}, minify),
globals(),
json(),
],
external: ['es6-promise/auto', 'aws-iot-device-sdk'],
exports: 'named',
context: 'self',
acorn: {
ecmaVersion: 8,
},
};
然而,当我尝试:
import awsIot from 'aws-iot-device-sdk';
console.log(awsIot);
无论如何,awsIot总是未定义的。我还在React Applicaiton中使用了aws-iot-device-sdk并像这样导入它 - 像魅力一样工作。
但是我不确定在Rollup这里我做错了什么?
感谢。
答案 0 :(得分:0)
我并不完全确定特定的sdk,但从我收集到的内容来看,aws-sdk一般来说,与目前的汇总隐含不兼容。
请查看此讨论: