glimmer-application-pipeline icon indicating copy to clipboard operation
glimmer-application-pipeline copied to clipboard

_typeof is not a function on commonjs import

Open topaxi opened this issue 7 years ago • 2 comments

I'm trying to import clipboard from npm. This results in _typeof is not a function which seems to be a function defined by babel to support es2015 symbols.

The imported module is plain JavaScript so babel transpilation seems unnecessary to me (but we might not know this while importing). I think it might be some rollup issue where _typeof is wrongly hoisted?

My ember-cli-build.js configuration:

'use strict';

const GlimmerApp = require('@glimmer/application-pipeline').GlimmerApp;
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');

module.exports = function(defaults) {
  let app = new GlimmerApp(defaults, {
    rollup: {
      plugins: [
        resolve({ jsnext: true, module: true, main: true }),
        commonjs()
      ]
    }
  });

  return app.toTree();
};

My component definition:

import Component from '@glimmer/component';
import Clipboard from 'clipboard/dist/clipboard';

export default class TmpyClipboard extends Component {
  args: { content: string };

  didInsertElement() {
    let clipboard = new Clipboard(this.element, {
      text: () => this.args.content
    });
  }
};

topaxi avatar Apr 16 '17 14:04 topaxi