I am trying to create shim for getstream library for ember-cli as @jmurphyau answered here.
I bower install getstream
, then create file
vendor/shims/getstream.js
(function() {
/* globals define, getstream */
function getstreamModule() {
'use strict';
return getstream; // <-- got error here
}
define('getstream', [], getstreamModule);
})();
and add lines to Brocfile.js
app.import('bower_components/getstream/dist/js_min/getstream.js');
app.import('vendor/shims/getstream.js', {
exports: {
'getstream': [ 'default' ]
}
});
and try to import Stream from 'getstream';
in route.
Got Uncaught ReferenceError: getstream is not defined
in getstream.js
What's going wrong and how it could be fixed? Thanks for answers.
Have you tried using ember-browsify?
That library doesn't look like it exposes a global variable called getstream
which is why your getting that error.
It does however look like it supports CommonJS module syntax so ember-browserify should work.
Install ember-browserify
ember install ember-browserify
Install the CommonJS library as an NPM package
npm install --save-dev getstream
Use the NPM package with regular import
syntax
import getstream from 'npm:getstream';