【问题标题】:aws-iot-device-sdk is undefined when bundled with rollupaws-iot-device-sdk 与汇总捆绑时未定义
【发布时间】:2018-09-09 14:00:15
【问题描述】:

我正在使用 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 做错了什么?

谢谢。

【问题讨论】:

    标签: javascript rollup aws-iot rollupjs


    【解决方案1】:

    我并不完全确定具体的 sdk,但从我收集的资料来看,总的来说,到目前为止,aws-sdk 与汇总不兼容。

    请查看此讨论:

    https://github.com/aws/aws-sdk-js/issues/1769

    【讨论】:

      猜你喜欢
      • 2018-09-26
      • 1970-01-01
      • 1970-01-01
      • 2018-12-03
      • 2021-09-01
      • 1970-01-01
      • 2017-09-18
      • 2016-05-07
      • 2017-09-26
      相关资源
      最近更新 更多