I'm integrating an ember project to use ember-tools because I want nice build tools. My project also uses epf, and I encountered a problem when I tried to include epf.js
as a library. My instinct was just to lump epf.js
into the vendor/
folder that ember-tools had generated for me... but this doesn't work. When I run ember build
it spits out the following:
Change detected: !config/app.js
created: js/templates.js
created: js/index.js
created: js/application.js
build time: 493 ms
Error: Cannot find module '/lib/version.js'
I think this is happening because epf.js
uses commonjs syntax, as in
require.define('/lib/index.js', function (module, exports, __dirname, __filename) {
global.Ep = Ember.Namespace.create();
require('/lib/version.js', module);
and ember-tools' build command thinks these require statements are declaring modules that it should build.
Is this a problem in general when using commonjs syntax? Is there some easy fix that will allow me to use ember-tools' build command to include epf.js
, or should I keep a separate lib folder somewhere and just put a <script>
tag in index.html
?
EDIT
epf.js begins,
(function(global) {
and exports the Ep
object as
global.Ep = Ember.Namespace.create();
This was causing problems, so I added global = window;
and var Ember = window.Em
. Later in the file there is a function called require
which I renamed to requireEPF
.
These terrible hacks have got me started, but I'd like to know if there is a better way.