Coder Social home page Coder Social logo

can-compile's Introduction

SauceLabs Test Status

Join our Slack Join our Discourse npm version Build Status Greenkeeper badge

CanJS is a collection of client-side JavaScript architectural libraries.

Web Components

CanJS’s StacheElement allows you to create Web Components with observable properties and live-bound templates.

class Counter extends StacheElement {
	static view = `
		Count: <span>{{ this.count }}</span>
		<button on:click="this.increment()">+1</button>
	`;

	static props = {
		count: 0
	};

	increment() {
		this.count++;
	}
}
customElements.define("my-counter", Counter);

Model layer

Components shouldn’t be concerned with how data is fetched, updated, or cached.

CanJS provides the right abstractions for your model code to be cleanly separated from your UI code. Learn more…

Promises in templates

CanJS’s stache templating language can directly read the state and values from Promises.

No need to write any extra code to determine whether a Promise is pending, resolved, or rejected. Learn more…

{{# if(this.promise.isPending) }}
  Loading…
{{/ if }}
{{# if(this.promise.isRejected) }}
  Error: {{ this.promise.reason }}
{{/ if }}
{{# if(this.promise.isResolved) }}
  Result: {{ this.promise.value }}
{{/ if }}

Real-time list updating

After data is created, updated, or destroyed, CanJS automatically updates your lists for you.

Filtering and sorting are preserved, so you don’t have to manually update your lists or fetch the same data again. Learn more…

Getting Started

Ready to get started? See the Setting Up CanJS, API Docs and Guides pages.

Support / Contributing

Before you make an issue, please read our Contributing guide.

You can find the core team on Slack.

Release History

See Releases.

License

MIT License.

can-compile's People

Contributors

bmomberger-bitovi avatar chasenlehara avatar daffl avatar designbyonyx avatar dfranz-freenow avatar eymaddis avatar greenkeeper[bot] avatar imaustink avatar marshallswain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

can-compile's Issues

Not working with stache and canjs 2.1.x

With the current version and canjs 2.1.x the output is:

   can.stache("<div></div>")

instead of

   can.view.preloadStringRenderer('templates_example_stache', can.stache("<div></div>"));

Which seems to be caused by 9080e53

Grunt 1.0 does not satisfy can-compile's peerDependencies requirements

Hi there -

I think can-compile's peerDependency on ~0.4.0 is causing a problem for grunt 1.0 installs, either local or global. Is it possible to add ^0.4.0 to allow for 1.0 versions of grunt? I don't think I can use this without forking as of now :(

Thanks for any help you may have. Here's the full error report:

npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants grunt@>=0.4.0
npm ERR! peerinvalid Peer [email protected] wants grunt@~0.4.0

npm ERR! System Linux 3.19.0-56-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "--save-dev" "can-compile"
npm ERR! cwd /home/***/client
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.4.21
npm ERR! code EPEERINVALID
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/***/npm-debug.log
npm ERR! not ok code 0

RequireJS Ejs loader

Could you transform this can-compile to a requirejs ejs-view loader.

So we could something like this?

define(['jquery', 'can/control', 'ejs!app/view/view', 'can/view/ejs'], function($, Control, tpl) { 
...
this.element.html(can.view(tpl, { }));
...
});

An in-range update of grunt is breaking the build 🚨

Version 1.0.3 of grunt was just published.

Branch Build failing 🚨
Dependency grunt
Current Version 1.0.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

grunt is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 10 commits.

  • 9ba3a99 1.0.3
  • eee4c33 Changelog v1.0.3
  • 46da7f2 Merge pull request #1636 from gruntjs/upt
  • 00f4d8a Drop support for Node 0.10 and 0.12
  • e852727 util update
  • 56d702e Update deps
  • 0105524 Fix race condition with file.mkdir and make it operate more similarily to mkdir -p (#1627) r=@vladikoff
  • 303d445 https links (#1629)
  • d969132 Merge pull request #1624 from gruntjs/rm-bump-deps
  • 289ff91 Remove old bump task and deps

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

can-compile doesn't work

I used canjs 1.1.8 version to develop a web app, used ejs(embed javascript) to handle the views templates. now i want to build all files .ejs with can-compile, i read the documentation here http://daffl.github.io/can-compile/#command-line but i doesn't work.

this is the content of my ejs file to make a test :

<ul class="bookmarkOptionsUl">
<li class="bookmarkoptions modifica">Modify</li>
<li class="bookmarkoptions elimina">Delete</li>

i run all command line wrote in documentation but nothing.

in this case i run

can-compile submenuBookmark.ejs --can 1.1.8
Compiling bookmark/views/bookmark.ejs

i get this error message : There was an error: undefined

TypeError: Cannot read property 'view' of undefined

Can't figure out why this is happening:

$ npm --version
1.3.24

$ nodejs --version
v0.10.25

$ npm install can-compile
[...]

$ ./node_modules/.bin/can-compile --version
0.5.0

$ touch test.ejs

$ ./node_modules/.bin/can-compile test.ejs
Compiling test.ejs

/home/aljosa/tmp/tmp1/node_modules/can-compile/lib/compile.js:55
var id = can.view.toId(normalizer(filename));
^
TypeError: Cannot read property 'view' of undefined
at /home/aljosa/tmp/tmp1/node_modules/can-compile/lib/compile.js:55:17
at /home/aljosa/tmp/tmp1/node_modules/can-compile/lib/compile.js:20:9
at /home/aljosa/tmp/tmp1/node_modules/can-compile/node_modules/jsdom/lib/jsdom.js:207:39
at process._tickCallback (node.js:415:13)

phantomjs "SyntaxError: Parse error"

not sure if it's actually can-compile issue but jshint gives errors only for views.js compiled using can-compile.
qunit/funcunit test works as expected in browser (like google chrome) but if i use grunt/qunit/phantomjs to run tests it breaks with "SyntaxError: Parse error".

any suggestions?

TypeError: Cannot read property 'view' of undefined

Hey

Out of nowhere i keep getting this error without modifying anything, it was working fine 3 days ago, the property win.can does not exists, is this something related to can 3.x release?

/Users/Paul/Work/js/desktop/node_modules/can-compile/lib/compile.js:57
var canViewTagsCallbacks = can.view.Scanner.tags || can.view.callbacks && can.view.callbacks._tags;
^

TypeError: Cannot read property 'view' of undefined
at /Users/Paul/Work/js/desktop/node_modules/can-compile/lib/compile.js:57:35
at /Users/Paul/Work/js/.desktop/node_modules/can-compile/lib/compile.js:19:9
at /Users/Paul/Work/js/desktop/node_modules/can-simple-window/lib/can-simple-window.js:27:4
at IncomingMessage.onEnd (/Users/Paul/Work/js/desktop/node_modules/can-simple-window/lib/doc-helpers.js:31:5)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:975:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)

Break and continue statements are considered illegal

Using break and continue statements in templates produces the following error upon compilation:

Fatal error: Illegal break statement

Example:

<% while(true) { %>
    <li>item</li>
    <% if (true) { %>
        <p>end</p>
        <% break; %>
    <% } %>
<% } %>

Remove external site dependanies

canjs.com got broken today and the releases dir is gone. Today is the day we found out that can-compile requires external site dependancies instead of relying on node_module dependancies. Our production builds are broken until the site is fixed. Can we please not have any external script dependancies in can-compile?

lib/resolveScripts.js is the file.

An in-range update of grunt-contrib-jshint is breaking the build 🚨

The devDependency grunt-contrib-jshint was updated from 1.1.0 to 2.0.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

grunt-contrib-jshint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 9 commits.

  • 2fce871 v2.0.0.
  • d9212b7 Document reporterOutputRelative option (#268)
  • d4fe674 Merge pull request #283 from gruntjs/dev
  • 35036cc Update deps, use https, fix failing test.
  • f1114ed Update mgol's name in AUTHORS, add .mailmap (#276)
  • 39daf69 Removing reference to dead jslinterrors.com site (#279)
  • debd964 v1.2.0 (#281)
  • 1f3519f Update deps (#280)
  • 2d237ee updated package grunt-contrib-internal from 1.1.0 to 1.2.3 (#273)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Very old node

Can js is depending on very old node version and grunt task keeps showing this warning
npm WARN engine [email protected]: wanted: {"node":"~0.10"} (current: {"node":"4.4.3","npm":"2.11.3"})

Could this line be removed from package.json?

Problem loading mustache components views into production

Hi,

We have a problem loading can components into prod file, when we run the prod with dev tools open we get the following error:

Uncaught Error: can.view: No template or empty template:app/src/views/components/datepicker_dropdown.mustache

We are using can compile from grunt like this:

cancompile: {
    options: {
        version: '2.3.13'
    },
    dist: {
        src: ['app/**/*.ejs', 'app/**/*.mustache', 'app/**/*.html'],
        dest: 'prod/views.js',
        options: {
            wrapper: 'define(\'views\', [\'can/view/mustache\'], function(can) { {{{content}}} });',
            tags: ['datepicker-dropdown']
        }
    }
}

If i look into the prod file i can see the following code when the template is loaded
e.view.preloadStringRenderer("app_src_views_components_datepicker_dropdown_mustache", e.Mustache(function(t, n) {....
Are we doing something wrong on the build process? The other templates are loading just fine, but all the components templates cannot be loaded.

Grunt 0.4 Release

I'm posting this issue to let you know that we will be publishing Grunt 0.4 on Monday, February 18th.

If your plugin is not already Grunt 0.4 compatible, would you please consider updating it? For an overview of what's changed, please see our migration guide.

If you'd like to develop against the final version of Grunt before Monday, please specify "grunt": "0.4.0rc8" as a devDependency in your project. After Monday's release, you'll be able to use "grunt": "~0.4.0" to actually publish your plugin. If you depend on any plugins from the grunt-contrib series, please see our list of release candidates for compatible versions. All of these will be updated to final status when Grunt 0.4 is published.

Also, in an effort to reduce duplication of effort and fragmentation in the developer community, could you review the grunt-contrib series of plugins to see if any of your functionality overlaps significantly with them? Grunt-contrib is community maintained with 40+ contributors—we'd love to discuss any additions you'd like to make.

Finally, we're working on a new task format that doesn't depend on Grunt: it's called node-task. Once this is complete, there will be one more conversion, and then we'll never ask you to upgrade your plugins to support our changes again. Until that happens, thanks for bearing with us!

If you have any questions about how to proceed, please respond here, or join us in #grunt on irc.freenode.net.

Thanks, we really appreciate your work!

Example doesn't work

Example doesn't even work, there is no production.html file in the example folder

Did anyone ever run the grunt in example folder before merge the PR into git ?

CanJS 2.1 Compatibility

View output for CanJS 2.0 uses the Scanner.hookupTag() method, which has been removed from can/view/scanner.js in CanJS 2.1. Is can.view.tag the replacement? I notice that it has a different API.

is this deprecated?

Its not anymore in the list of v3 Modules on the v3 CanJS page but its in the docs in the Building CanJS part.

Dosent install with npm on Windows

I just want to install it on Windows 7 and the command console shows errors :

> [email protected] install C:\Users\b.cherif\AppData\Roaming\npm\node_modules\ca
n-compile\node_modules\jsdom\node_modules\contextify
> node-gyp rebuild


C:\Users\b.cherif\AppData\Roaming\npm\node_modules\can-compile\node_modules\jsdo
m\node_modules\contextify>node "C:\Program Files\nodejs\node_modules\npm\bin\nod
e-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack     at failNoPython (C:\Program Files\nodejs\node_modules\npm\nod
e_modules\node-gyp\lib\configure.js:101:14)
gyp ERR! stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:64:11
gyp ERR! stack     at Object.oncomplete (fs.js:107:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modu
les\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\b.cherif\AppData\Roaming\npm\node_modules\can-compile\node
_modules\jsdom\node_modules\contextify
gyp ERR! node -v v0.10.24
gyp ERR! node-gyp -v v0.12.1
gyp ERR! not ok
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the contextify package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls contextify
npm ERR! There is likely additional logging output above.

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "can-compile" "-g"
npm ERR! cwd E:\myapp
npm ERR! node -v v0.10.24
npm ERR! npm -v 1.3.21
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     E:\myapp\npm-debug.log
npm ERR! not ok code 0

jquery not found

Hi , I am using jquery in my can js application.

I had followed all the rultes as you specified in the documentation .

After completion of minification in the browser console it shows jquery not found , $ not found errors.

Can't get it to work

The following outputs 3 files:
production/views.production.js contains: !function() { }();
production/production.js contains: !function() { }();
production/production.min.js is empty.

Running "cancompile" task

Running "cancompile:dist" (cancompile) task
Verifying property cancompile.dist exists in config...OK
Files: test/catMerchList_view.ejs, test/breadcrumb_view.mustache, test/featuredStores_view.mustache -> production/views.production.js
Options: version="0.8.0", wrapper="!function() { {{{content}}} }();"
Compiling test/catMerchList_view.ejs

Running "concat" task

Running "concat:dist" (concat) task
Verifying property concat.dist exists in config...OK
Files: production/views.production.js -> production/production.js
Options: separator="\r\n", banner="", footer="", stripBanners=false, process=false, sourceMap=false, sourceMapName=undefined, sourceMapStyle="embed"
Reading production/views.production.js...OK
Writing production/production.js...OK
File production/production.js created.

Running "uglify" task

Running "uglify:dist" (uglify) task
Verifying property uglify.dist exists in config...OK
Files: production/production.js -> production/production.min.js
Options: banner="", footer="", compress={"warnings":false}, mangle={}, beautify=false, report="min", expression=false, maxLineLen=32000, ASCIIOnly=false, screwIE8=false
Minifying with UglifyJS...Reading production/production.js...OK
OK
Writing production/production.min.js...OK
File production/production.min.js created: 19 B → 0 B

1 file created.

Done, without errors.

Compiling with the latest CanJS version if a version isn't specified causes unexpected breakage

I struggled for several hours with a compilation bug that popped up suddenly. The templates we've compiled successfully for months stopped working. Today I discovered that even though we've been running CanJS 2.0.7 and we haven't upgraded, can compile was remote-fetching 2.1 (latest) and compiling the templates with that code. And, then, when we ran those compiled templates against our 2.0.7 codebase it breaks (although a surprising amount of it still works).

2.1 only came out a few days ago so of course we haven't upgraded.

The solution is to specify a 'version' in the grunt config like so:

       cancompile: {
            dist: {
                src: [mediaDirectory + '/templates/*.mustache'],
                out: jsBaseDirectory + '/views.production.js',
                wrapper: 'define(["can/view/mustache"], function(can) { {{{content}}} });',
                version: '2.0.7'
            }

But this behavior was totally unexpected and threw everyone for a loop because we didn't change a thing.

This should at least be called out as a mandatory parameter in the documentation.

Compiled .ejs doesn't render with RequireJS + Almond app

Hey Daffl,

I'm building an app with RequireJS, compiled through Almond for production. Using latest CanJS (2.0.3) with EJS views.

I can get can-compile to work with RequireJS's build through Grunt, and I can see the compiled view in the build at the end of the file. But when running my builded app the view is not rendered.

Here's my require-config which grunt runs through grunt-contrib-requirejs:

// requirejs global config
require.config({
    baseUrl: '/static/js/gamificationamd/src',
    paths: {
        almond: "../../vendor/almond/almond",
        jquery: '../../vendor/jquery/jquery',
        xdomainrequest: '../../vendor/xdomainrequest/xdomainrequest-amd',
        can: '../../vendor/can/can',
        jquerycookie: '../../vendor/jquerycookie/jquerycookie',
        tooltipster: '../../vendor/tooltipster/js/jquery.tooltipster.amd',
        config: 'config/config',
        bar: 'bar/bar',
        views: 'views/build'
    },
    map: {
        // http://requirejs.org/docs/jquery.html#noconflictmap
        '*': {
            'jquery': 'jquery-private'
        },
        'jquery-private': { 'jquery': 'jquery' },
    }
});

And my concerned Grunt tasks:

// Can-compile to include EJS views in RequireJS Build
    cancompile: {
      bar: {
        src: ['static/js/gamificationamd/src/**/*.ejs'],
        out: 'static/js/gamificationamd/src/views/build/views.js',
        wrapper: 'define(["can/view/ejs"], function(can) { {{{content}}} });'
      }
    },

    // RequireJS for build version of bar
    requirejs: {
      bar: {
        options: {
          baseUrl: 'static/js/gamificationamd/src',
          mainConfigFile: 'static/js/gamificationamd/src/require-config.js',
          deps: ['gamificationamd'],
          insertRequire: ['gamificationamd'],
          name: '../../vendor/almond/almond',
          out: 'static/js/gamificationamd/bar.js',
          optimize: 'uglify2',
          generateSourceMaps: false,
          preserveLicenseComments: false,
          findNestedDependencies: true,
          wrap: true
        },
      },
    }

Thanks

Can Compile output didn't work properly with CanJS 2.1

Two issues. One was easy, the compiled template file calls can.view.preload, but should call can.view.preloadStringRenderer.

The other I'm not clear on. In can.ejs from 2.1.1 there is the following lines:
viewData.templateType = "legacy";
if (viewData.tagName) {
viewCallbacks.tagHandler(el, viewData.tagName, viewData);
}

For certain templates, viewData was undefined. Wrapping these lines with a test for the presence of viewData seems to have fixed things. Tests show the templates that were causing the problem rendered correctly. Stopped trying to figure out why this was happening.

An in-range update of through2 is breaking the build 🚨

The dependency through2 was updated from 2.0.3 to 2.0.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

through2 is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 4 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Should be pipe-able in a gulp chain, and the task helper should allow optional dependencies

The library should be able to sit in between gulp.src and gulp.dest streams - just like other gulp plugins:

var compiler = require('can-compile/gulp');

gulp.task('cancompile', function () {
   return gulp.src('path/to/templates')
       .pipe( compiler('views.production.js') )
       .pipe( gulp.dest('path/to/dist') );
});

Also, the .task helper should allow for optional dependencies (notice [clean]):

var compiler = require('can-compile/gulp');
compiler.task('cancompile', {
    version: '2.2.7',
    src: 'glob/to/source/*/**'
    out: 'path/to/dest/views.templates.js'
}, gulp, ['clean']);

An in-range update of glob is breaking the build 🚨

Version 7.1.3 of glob was just published.

Branch Build failing 🚨
Dependency glob
Current Version 7.1.2
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

glob is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 3 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Can compile it's failing on redirects

Im trying to use can compile to build a project but it's failing for few days now, because of this url

http://canjs.com/release/2.3.5/can.jquery.js

Which returns

<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.2.1</center>
</body>
</html>

The right url it starts with https

Views compile issue

I compile my views with this

 cancompile: {
      options: {
        version: '2.1.1'
      },
      dist: {        
        src: ['**/*.mustache'],
        dest: 'production/views.production.js'
      }
    },

and concat it with this

concat: {
      dist: {
          src: [
          'bower_components/jquery/dist/jquery.js',
          'bower_components/canjs/can.jquery.js',
          'bower_components/bootstrap/dist/js/bootstrap.js',
          //'js/**/*.js'
              'js/models/placetype.js',
              'js/models/place.js',
              'js/components/place/filter/filter.js',
              'js/components/place/list/list.js',
              'js/components/place/item/item.js',
              'js/components/placetype/filter/filter.js',
              'js/components/place/map/map.js',
              'js/pages/test/home/home.js',
              'js/pages/test/place/place.js',
              'js/pages/home/home.js',
              'js/pages/about/about.js',
              'js/pages/place/place.js',
          'js/app.js', // You app
          '<%= cancompile.dist.dest %>' // The compiled views
        ],
        dest: 'production/production.js'
      }

But if i run my app with the created production.js it tell's me "can.view: No template or empty template"

Here an example of a controller:

    can.Component.extend({
        tag: 'placetypefilter',
        template: can.view('js/components/placetype/filter/views/filter.mustache'),

In the views.production.js i have code like this:

can.view.preloadStringRenderer('\js\components\place\filter\views\filter_mustache', .....

vulnerabilities found - npm audit

npm audit

added 74   packages from 81 contributors and removed 46 packages in 16.781s     [!] 4 vulnerabilities found [337533 packages audited]         Severity: 2 Low \| 2 High         Run `npm audit` for more   detail                                          === npm audit   security report ===                                     

             Manual Review                  Some vulnerabilities   require your attention to resolve                    Visit   https://go.npm.me/audit-guide for additional guidance          

       High            Regular Expression Denial of Service            Package         minimatch            Patched in      >=3.0.2            Dependency of   can-compile            Path            can-compile > glob > minimatch            More info         https://nodesecurity.io/advisories/118       

          High            Cross-Site Scripting            Package         handlebars            Patched in      >=4.0.0            Dependency of   can-compile            Path            can-compile > handlebars            More info         https://nodesecurity.io/advisories/61            

     Low             Incorrect Handling of   Non-Boolean Comparisons During                       Minification            Package         uglify-js            Patched in      >= 2.4.24            Dependency of   can-compile            Path            can-compile > handlebars >   uglify-js            More info         https://nodesecurity.io/advisories/39         

        Low             Regular Expression Denial of   Service            Package         uglify-js            Patched in      >=2.6.0            Dependency of   can-compile            Path            can-compile > handlebars >   uglify-js            More info         https://nodesecurity.io/advisories/48               [!] 4 vulnerabilities found - Packages audited: 337533 (0 dev, 0   optional)         Severity: 2 Low \| 2 High
--





Please add a baseUrl

For relative paths, just like grunt-contrib-requirejs. It would make it easier to customize things without the need for a customize normalizer, which is probably best for more advanced customizations.

Remove dependencies on core CanJS and DOM libraries to increase Node compatibility

While such dependencies are fine if you can work with a global Node.js installation and a working npm install of jsdom (and crucially; contextify), it completely bombs when trying to integrate with existing build-chains.

This is a problem in particular for MSBuild-driven builds such as is the case with Visual Studio or TFS build server.

How hard would it be to use only the EJS compiler itself to produce the template and nothing else? (Or alternatively; how hard would it be to shim a minimal underlying DOM library on which to build up CanJS?)

use pre-compile views with RequireJS (can-compile)

i have a multiple page app and i used can-compile NodeJS module that compiles CanJS EJS views into a single JavaScript file for lightning fast production apps in my project. (i use canjs, requirejs, ejs.js for templates):

i followed these instructions to set my grunt task [https://github.com/daffl/can-compile][1] to compile ejs files.

i added a new file js and i called views.production.js in my proyect with content :

define('views', function() {});

my build.js file :

({
    "appDir" : "../www",
    "baseUrl" : "js/lib",
    "fileExclusionRegExp": /^(appcaches|lr|test|mockups|doc|fixtures|(index)\.html|(fixtures)\.js|.*\.less|.*\.json|.*\.ejs)$/,
    "optimizeCss": "standard",
    "removeCombined": true,
    //"findNestedDependencies" : true,
    "preserveLicenseComments" : false,
    "logLevel" : 0,
    "paths" : {
        "app" : "../app",
        "tools" : "../../../tools",
        "jquery" : "jquery-2.0.3.min",
        "jquery-ui" : "plugins/jquery-ui-1.10.4.custom.min",
        "jquery-ui-touch-punch" : "plugins/jquery.ui.touch-punch.min",
        "bootstrap" : "bootstrap.min",
        "underscore" : "underscore.min",
        "can" : "can",
        "aria" : "aria",
        "models" : "../app/common/models",
        //folder directory for documentation
        "doc" : "../doc",
        "async" : "require/async",
        "goog" : "require/goog",
        "propertyParser" : "require/propertyParser",
        "google-api" : "aria/google_api/google-api-engine",
        "google-maps" : "aria/google_api/google-maps-engine",
        "collaboration" : "../app/collaboration",
        "swipe" : "plugins/swipe2",
        "animend-transend" : "plugins/jquery.animend.transend",
        "jquery-validate" : "plugins/jquery.validate.min",
        "jcrop" : "plugins/jcrop/js/jquery.Jcrop.min",
        "spin" : "plugins/spin",
        "ftscroller" : "plugins/ftscroller",
        "owl-carousel" : "plugins/owl.carousel.min",
        'shared_resource' : '../shared_resource',
        'views' : '../views.production'
    },
    'shim' : {
        'jquery' : {
            'exports' : '$'
        },
        'bootstrap' : {
            'deps' : ['jquery', 'jquery-ui']
        },
        'underscore' : {
            'exports' : '_'
        },
        'jquery-ui' : {
            'deps' : ['jquery']
        },
        'jquery-ui-touch-punch' : {
            'deps' : ['jquery-ui']
        },
        'swipe' : {
            'deps' : ['jquery'],
                'exports' : 'Swipe'
        },
        'animend-transend' : {
            'deps' : ['jquery']
        },
        'jquery-validate' : {
            'deps' : ['jquery']
        },
        'jcrop' : {
            'deps' : ['jquery']
        },
        'owl-carousel' : {
            'deps' : ['jquery']
        }
    },
    "dir" : "../www-built",
    "modules" : [
        {
            "name" : "../common",
            "include" : [
                'jquery',
                'aria',
                'app/common/error_handler',
                'app/common/vocal',
                'views'
            ]
        },{
            "name" : "../shared_resource",
            "include" : [
                'app/common/models',
                'app/common/header/controllers/header',
                'google-maps',
                'google-api',
                'app/common/widgets/controllers/select_bank_account',
                'app/timeline/sidebar/bookmark/controllers/bookmark',
                'app/timeline/create_bookmark/controllers/create_bookmark',
                'app/desire/controllers/moneyBox',
                'plugins/fullcalendar/fullcalendar',
                'plugins/bootstrap_slider',
                'app/timeline/summaries/summaries',
                'app/timeline/sidebar/summaries/summaries',
                'app/common/product_filter/controllers/product_filter',
                'app/common/product_filter/item/controllers/item',
                'app/common/calendar/controllers/calendar',
                'app/common/widgets/controllers/insert_pin',
                'app/common/operation',
                'app/common/operation_helper',
                'app/common/datepicker_dropdown/controllers/datepicker_dropdown',
                'app/dispositive/bill/common/controllers/bill_base',
                'app/dispositive/bill/common/controllers/address',
                'app/dispositive/bill/common/controllers/due_date',
                'app/common/widgets/controllers/send_email',
                'app/common/draggable_list_menu/controllers/draggable_list_menu'
            ],
            "exclude" : [
                "../common"
            ]
        },
        {
            "name" : "../login",
            "include" : [
                "app/login/main",
                "app/login/controllers/login"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../homepage",
            "include" : [
                "app/homepage/main",
                "app/homepage/controllers/homepage"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../cerca_uffici_bancomat",
            "include" : [
                "app/cerca_uffici_bancomat/main",
                "app/cerca_uffici_bancomat/controllers/cerca_uffici_bancomat"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../collaboration",
            "include" : [
                "app/collaboration/main",
                "app/collaboration/controllers/collaboration"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../collaboration_bank",
            "include" : [
                "app/collaboration/main_bank",
                "app/collaboration/controllers/collaboration"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../contacts",
            "include" : [
                "app/contacts/main",
                "app/contacts/controllers/contacts"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../crop",
            "include" : [
                "app/crop/main",
                "app/crop/controllers/crop"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../desire",
            "include" : [
                "app/desire/main",
                "app/desire/controllers/desire"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../feed",
            "include" : [
                "app/feed/main",
                "app/feed/controllers/feed"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../help",
            "include" : [
                "app/help/main",
                "app/help/controllers/router",
                "app/help/controllers/help"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../news",
            "include" : [
                "app/homepage/main_news",
                "app/homepage/controllers/news"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../patrimonio",
            "include" : [
                "app/patrimonio/main",
                "app/patrimonio/controllers/patrimonio"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../personal_area",
            "include" : [
                "app/personal_area/main",
                "app/personal_area/controllers/personal_area"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../search",
            "include" : [
                "app/search/main",
                "app/search/controllers/search"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../timeline",
            "include" : [
                "app/timeline/main",
                "app/timeline/controllers/timeline",
                'app/timeline/sidebar/controllers/sidebar',
                'app/timeline/router'
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../tweet",
            "include" : [
                "app/tweet/main",
                "app/tweet/controllers/tweet"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../delete_recurrent_transfer",
            "include" : [
                "app/dispositive/automatic_transfer/delete_recurrent_transfer",
                "app/dispositive/automatic_transfer/controllers/delete/delete_recurrent_transfer"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../delete_scheduled_transfer",
            "include" : [
                "app/dispositive/automatic_transfer/delete_scheduled_transfer",
                "app/dispositive/automatic_transfer/controllers/delete/delete_scheduled_transfer"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../edit_recurrent_transfer",
            "include" : [
                "app/dispositive/automatic_transfer/edit_recurrent_transfer",
                "app/dispositive/automatic_transfer/controllers/edit/edit_recurrent_transfer"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../edit_scheduled_transfer",
            "include" : [
                "app/dispositive/automatic_transfer/edit_scheduled_transfer",
                "app/dispositive/automatic_transfer/controllers/edit/edit_scheduled_transfer"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../new_recurrent_transfer",
            "include" : [
                "app/dispositive/automatic_transfer/new_recurrent_transfer",
                "app/dispositive/automatic_transfer/controllers/new/new_recurrent_transfer"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../new_scheduled_transfer",
            "include" : [
                "app/dispositive/automatic_transfer/new_scheduled_transfer",
                "app/dispositive/automatic_transfer/controllers/new/new_scheduled_transfer"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../resume_recurrent_transfer",
            "include" : [
                "app/dispositive/automatic_transfer/resume_recurrent_transfer",
                "app/dispositive/automatic_transfer/controllers/resume/resume_recurrent_transfer"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../suspend_recurrent_transfer",
            "include" : [
                "app/dispositive/automatic_transfer/suspend_recurrent_transfer",
                "app/dispositive/automatic_transfer/controllers/suspend/suspend_recurrent_transfer"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../bill_free",
            "include" : [
                "app/dispositive/bill/bill_free/main",
                "app/dispositive/bill/bill_free/controllers/bill_free"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../bill_free_custom",
            "include" : [
                "app/dispositive/bill/bill_free/bill_free_custom/main",
                "app/dispositive/bill/bill_free/bill_free_custom/controllers/bill_free_custom"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../bill_free_other",
            "include" : [
                "app/dispositive/bill/bill_free/bill_free_other/main",
                "app/dispositive/bill/bill_free/bill_free_other/controllers/bill_free_other"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../bill_marked",
            "include" : [
                "app/dispositive/bill/bill_marked/main",
                "app/dispositive/bill/bill_marked/controllers/bill_marked"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../bill_marked_import",
            "include" : [
                "app/dispositive/bill/bill_marked/bill_marked_import/main",
                "app/dispositive/bill/bill_marked/bill_marked_import/controllers/bill_marked_import"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../mav",
            "include" : [
                "app/dispositive/bill/mav/main",
                "app/dispositive/bill/mav/controllers/mav"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../rav",
            "include" : [
                "app/dispositive/bill/rav/main",
                "app/dispositive/bill/rav/controllers/rav"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../riba",
            "include" : [
                "app/dispositive/bill/riba/main",
                "app/dispositive/bill/riba/controllers/riba"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../car_tax",
            "include" : [
                "app/dispositive/car_tax/main",
                "app/dispositive/car_tax/controllers/car_tax"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../dollar_trade",
            "include" : [
                "app/dispositive/dollar_trade/main",
                "app/dispositive/dollar_trade/controllers/dollar_trade"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../lock_current_account",
            "include" : [
                "app/dispositive/lock_unlock/lock_current_account",
                "app/dispositive/lock_unlock/controllers/lock/lock_current_account"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../lock_deposit_account",
            "include" : [
                "app/dispositive/lock_unlock/lock_deposit_account",
                "app/dispositive/lock_unlock/controllers/lock/lock_deposit_account"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../unlock_current_account",
            "include" : [
                "app/dispositive/lock_unlock/unlock_current_account",
                "app/dispositive/lock_unlock/controllers/unlock/unlock_current_account"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../unlock_deposit_account",
            "include" : [
                "app/dispositive/lock_unlock/unlock_deposit_account",
                "app/dispositive/lock_unlock/controllers/unlock/unlock_deposit_account"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../paypal_send_money",
            "include" : [
                "app/dispositive/paypal/bank_transfer/main",
                "app/dispositive/paypal/bank_transfer/controllers/bank_transfer"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../giro_card_top_up",
            "include" : [
                "app/dispositive/top_up/giro_card_top_up",
                "app/dispositive/top_up/controllers/card/giro_card_top_up"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../mediaset_premium_top_up",
            "include" : [
                "app/dispositive/top_up/mediaset_premium_top_up",
                "app/dispositive/top_up/controllers/tv/mediaset_premium_top_up"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../money_service_card_top_up",
            "include" : [
                "app/dispositive/top_up/money_service_card_top_up",
                "app/dispositive/top_up/controllers/card/money_service_card_top_up"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../new_generation_card_top_up",
            "include" : [
                "app/dispositive/top_up/new_generation_card_top_up",
                "app/dispositive/top_up/controllers/card/new_generation_card_top_up"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../riflex_cash_card_top_up",
            "include" : [
                "app/dispositive/top_up/riflex_cash_card_top_up",
                "app/dispositive/top_up/controllers/card/riflex_cash_card_top_up"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../tim_mobile_top_up",
            "include" : [
                "app/dispositive/top_up/tim_mobile_top_up",
                "app/dispositive/top_up/controllers/mobile/tim_mobile_top_up"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../tre_mobile_top_up",
            "include" : [
                "app/dispositive/top_up/tre_mobile_top_up",
                "app/dispositive/top_up/controllers/mobile/tre_mobile_top_up"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../vodafone_mobile_top_up",
            "include" : [
                "app/dispositive/top_up/vodafone_mobile_top_up",
                "app/dispositive/top_up/controllers/mobile/vodafone_mobile_top_up"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../wind_mobile_top_up",
            "include" : [
                "app/dispositive/top_up/wind_mobile_top_up",
                "app/dispositive/top_up/controllers/mobile/wind_mobile_top_up"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        },
        {
            "name" : "../bank_transfer",
            "include" : [
                "app/dispositive/bank_transfer/main",
                "app/dispositive/bank_transfer/bank_transfer"
            ],
            "exclude" : [
                "../common",
                "../shared_resource"
            ]
        }

    ],
    "optimize": "uglify2",
    "uglify2": {
        "compress": {
            "drop_console": true  // drops "console.log" statements
        }
    }
})

my common.js file :

requirejs.config({
    'baseUrl' : 'js/lib',
    'paths' : {
        'app' : '../app',
        'tools' : '../../../tools',
        'jquery' : 'jquery-2.0.3.min',
        'jquery-ui' : 'plugins/jquery-ui-1.11.1.custom.min',
        'jquery-ui-touch-punch' : 'plugins/jquery.ui.touch-punch.min',
        'jquery-scroll-table-body': 'plugins/jquery.scrollTableBody.min',
        'bootstrap' : 'bootstrap.min',
        'underscore' : 'underscore.min',
        'can' : 'can',
        'aria' : 'aria',
        'models' : '../app/common/models',
        'fixtures' : '../app/common/fixtures',
        //folder directory for documentation
        'doc' : '../doc',
        'async' : 'require/async',
        'goog' : 'require/goog',
        'propertyParser' : 'require/propertyParser',
        'google-api' : 'aria/google_api/google-api-engine',
        'google-maps' : 'aria/google_api/google-maps-engine',
        'collaboration' : '../app/collaboration',
        'swipe' : 'plugins/swipe2',
        'animend-transend' : 'plugins/jquery.animend.transend',
        'jquery-validate' : 'plugins/jquery.validate.min',
        'jcrop' : 'plugins/jcrop/js/jquery.Jcrop.min',
        'spin' : 'plugins/spin',
        'ftscroller' : 'plugins/ftscroller',
        'owl-carousel' : 'plugins/owl.carousel.min',
        'state-machine' : 'plugins/state-machine.min',
        'shared_resource' : '../shared_resource',
        'views' : '../views.production'
    },
    'shim' : {
        'jquery' : {
            'exports' : '$'
        },
        'bootstrap' : {
            'deps' : ['jquery', 'jquery-ui']
        },
        'underscore' : {
            'exports' : '_'
        },
        'jquery-scroll-table-body' : {
            'deps' : ['jquery']
        },
        'jquery-ui' : {
            'deps' : ['jquery']
        },
        'jquery-ui-touch-punch' : {
            'deps' : ['jquery-ui']
        },
        'swipe' : {
            'deps' : ['jquery'],
            'exports' : 'Swipe'
        },
        'animend-transend' : {
            'deps' : ['jquery']
        },
        'jquery-validate' : {
            'deps' : ['jquery']
        },
        'jcrop' : {
            'deps' : ['jquery']
        },
        'owl-carousel' : {
            'deps' : ['jquery']
        }

    }
});

require([
    'jquery',
    'aria',
    'app/common/error_handler',
    'app/common/vocal',
    'views'
], function (jQuery, AriaTouch) {

    //export AriaTouch
    window.AriaTouch = AriaTouch;

    var protocol,
        host,
        url,
        routeLR = '/lr',
        routeJB = '/jb',
        routeMB = '/mb/media',
        routePublic = '/public',
        fixflag = false,
        ENV,
        testIntegrazione,
        cacheDebug = false,
        instance,
        vocalInstance,
        vocalUtils,
        gaAccount,
        setupAjaxWithCredentials = function () {
            jQuery.ajaxSetup({
                'xhrFields' : {
                    'withCredentials' : true
                }
            });
        };

    console.log('%c AriaTouch - standalone: %s', 'background: #222; color: #bada55', window.standalone);

    // non sono wrappato
    if (!window.standalone) {
        console.log('%c AriaTouch - App NOT Standalone Mode', 'background: #222; color: #bada55');
        ENV = 'local';
        jQuery('body').addClass('notStandalone');
    }
    // sono wrappato
    else {
        console.log('%c AriaTouch - App Standalone Mode', 'background: #222; color: #bada55');
        window.ENV = window.ENV.toLowerCase();
        //window.ENV = "prod";
        ENV = window.ENV;
        if (!window.noAjaxBridge) {
            AriaTouch.Bridge.initAjaxTransport();
        } else {
            setupAjaxWithCredentials();
        }
    }

    if (!cacheDebug) {
        testIntegrazione = AriaTouch.Storage.Session.decode(sessionStorage.testIntegrazione) || AriaTouch.Location.getQueryStringParameterByName('testIntegrazione');
    } else {
        testIntegrazione = sessionStorage.testIntegrazione || AriaTouch.Location.getQueryStringParameterByName('testIntegrazione');
    }

    if (testIntegrazione !== '') {
        if (!cacheDebug) {
            ENV = testIntegrazione;
            sessionStorage.testIntegrazione = AriaTouch.Storage.Session.encode(testIntegrazione);
        } else {
            sessionStorage.testIntegrazione = testIntegrazione;
            ENV = testIntegrazione;
        }

        console.log('%c AriaTouch - Test Integrazione Ambiente - %s', 'background: #222; color: #bada55', ENV);
        setupAjaxWithCredentials();
    }

    // FQDN
    // svil-tablet.bmedmobile.it
    // test-tablet.bmedmobile.it
    // preprod-tablet.bmedmobile.it
    // tablet.bmedmobile.it
    switch (ENV) {
        case 'dev':

            protocol = 'http';
            host = 'svil-tablet.mobile.bmedonline.it:8081';
            url = protocol + '://' + host;
            gaAccount = "UA-56471437-3";
            break;

        case 'test':

            protocol = 'https';
            host = 'test-tablet.bmedmobile.it';
            url = protocol + '://' + host;
            gaAccount = "UA-56788866-1";
            break;

        case 'prod':

            protocol = 'https';
            host = 'tablet.bmedmobile.it';
            url = protocol + '://' + host;
            gaAccount = "UA-56931372-1";
            break;

        case 'local':
        default:

            protocol = window.location.protocol;
            host = window.location.host;
            url = protocol + '//' + host;
            fixflag = true;
            gaAccount = "local";
            break;

    }

    if (fixflag) {
        // set fixture's random delay
        can.fixture.delay = Math.floor((Math.random() * 600) + 1);
        require(['app/common/fixtures']);
    }

    instance = AriaTouch.Page.getInstance({
        'service': {
            'bases': {
                'baseUrl' : url,
                'urlPrefix' : url + routeJB,
                'urlPrefixMediaBus' : url + routeMB,
                'urlPrefixLR' : url + routeLR,
                'urlPrefixPublic' : url + routePublic,
                'urlPrefixNMol' : 'https://www.bmedonline.it'
            },
            'fixture': {
                'enable': fixflag
            }
        },
        'caching' : {
            'enable' : true,
            'debug' : cacheDebug
        },
         'debugJB' : {
            'enable' : false
        },
        'tracker' : {
            'enable' : true
        }
    });

    AriaTouch.Tracker.getInstance({
        'account' : gaAccount
    });

    //*** Caching rotte servizi ***
    AriaTouch.Cache.getInstance().addRoute('/MenuItem/');
    AriaTouch.Cache.getInstance().addRoute('/Account/list/');
    AriaTouch.Cache.getInstance().addRoute('/Account/nondep');
    AriaTouch.Cache.getInstance().addRoute('/Customer');
    AriaTouch.Cache.getInstance().addRoute('/Asset');
    AriaTouch.Cache.getInstance().addRoute('/TimelineType');
    AriaTouch.Cache.getInstance().addRoute('/TimelineActionBst');
    AriaTouch.Cache.getInstance().addRoute('/Bonifico/elencoStatiBonificoEstero');
    //togliamo la getDefaultAcount, il conto di default puo essere modificato
    //AriaTouch.Cache.getInstance().addRoute('/Account/getContoDefault');


    //***

    console.log('FROM COMMON',instance);

    instance['@data'].set('ENV', ENV, 'session');

    //Listening to ajax errors
    instance.getChannelByName('errors').subscribe(AriaTouch.Exception.Ajax, App.Common.ErrorHandler.ajaxHandler);

    //Listening to errors from native
    instance.getChannelByName('errors').subscribe(AriaTouch.Exception.Generic, App.Common.ErrorHandler.genericHandler);

    //Listening to offline events
    instance.getChannelByName('errors').subscribe(AriaTouch.Exception.Offline, App.Common.ErrorHandler.offlineHandler);

    //init vocal with custom bridge
    vocalInstance = AriaTouch.Vocal.getInstance({
        'bridge' : App.Common.VocalBridge.getInstance()
    });



    vocalUtils = App.Common.VocalUtils.getInstance({
        "menuItemByProduct" : AriaTouch.Storage.Session.get("menuItemByProduct")
    });

    vocalInstance.subscribe(new App.Common.VocalIntentions.Navigation, function (ev, evData) {

        var intention = evData.intention,
            vocalIntention = vocalUtils.getUrlByIntention(intention, evData);

        if(vocalIntention.url==="@noProductAvailable") {
            console.log("noProductAvailable exception");
            return false;
        }
        if(vocalIntention.url==="@notYetImplemented") {
            console.log("notYetImplemented exception");
            return false;
        }

        if(vocalIntention.url==="@exitApp") {
            console.log("exit application, skip the navigate");
            return false;
        }

        if (!_.isEmpty(evData)) {
            //conversazionale
            AriaTouch.Location.setFlashData(intention, evData);
        }

        var data = {
            intention : intention,
            navigationState : "step-nav",
            page: vocalIntention.url,
            dispose: vocalIntention.dispose
        };


        AriaTouch.Location.navigate(vocalIntention.url, '', '');
        AriaTouch.Vocal.getInstance().heyVocal(new App.Common.VocalIntentions.ImReady(data));

    });

    vocalInstance.subscribe(new App.Common.VocalIntentions.Conversation, function (ev, evData) {

        var intention = evData.intention,
            vocalIntention = vocalUtils.getUrlByIntention(intention, evData);


        if(vocalIntention.url==="@noProductAvailable") {
            console.log("noProductAvailable exception");
            return false;
        }
        if(vocalIntention.url==="@notYetImplemented") {
            console.log("notYetImplemented exception");
            return false;
        }

        if (!_.isEmpty(evData)) {
            //conversazionale
            AriaTouch.Location.setFlashData(intention, evData);
        }

        AriaTouch.Location.navigate(vocalIntention.url, '', '', false, true);

    });

    vocalInstance.subscribe(new App.Common.VocalIntentions.Search, function (ev, evData) {

        var intention = evData.intention,
            vocalIntention = vocalUtils.getUrlByIntention(intention, evData);


        if(vocalIntention.url==="@noProductAvailable") {
            console.log("noProductAvailable exception");
            return false;
        }
        if(vocalIntention.url==="@notYetImplemented") {
            console.log("notYetImplemented exception");
            return false;
        }

        $.when(App.Common.Models.MenuItem.getMenuItem100()).then(function (dataMenu100) {
            App.Common.Models.MenuItem.preProcessMenuItem($.extend({}, dataMenu100.attributes));
            $.when(App.Common.ProductFilter.vocalPreFilter(intention, evData.vocals)).then(function(data) {
                if(typeof data.vocalError!=="undefined") {
                    AriaTouch.Vocal.getInstance().heyVocal(new App.Common.VocalException.FailedFieldsValidation(data.vocalError));
                    return false;
                }
                if(typeof data.results!=="undefined") {
                    if(data.results.length>0) {
                        if (!_.isEmpty(evData)) {
                            //conversazionale
                            AriaTouch.Location.setFlashData(intention, evData);
                        }
                        AriaTouch.Location.navigate(vocalIntention.url, '', App.Common.VocalUtils.getInstance().getHashFromVocalParams(evData), false, true);
                    } else {
                        var vocalError =  {
                            'intention' : intention,
                            'name' : 'NO_RESULTS',
                            'description' : 'no results for this timeline filter'
                        }
                        AriaTouch.Vocal.getInstance().heyVocal(new App.Common.VocalException.FailedFieldsValidation(vocalError));
                        return false;
                    }
                }
            });
        });


    });

    //Aggiungo i data con le info del dispositivo
    //http://theiphonewiki.com/wiki/Models
    if(typeof window.platform!=="undefined") {
        $('body').attr({
            'data-platform' : window.platform,
            'data-hardware' : window.hardware,
            'data-systemName' : window.systemName,
            'data-systemVersion' : window.systemVersion,
            'data-model' : window.model,
            'data-iPadModel' : window.iPadModel
        });

    }

});

the i create a grunt task to pre-compile ejs files :

this is my Gruntfile.js task :

module.exports = function (grunt) {

    // Project configuration.
    grunt.initConfig({
        cancompile: {
            options: {
                version: '1.1.8',

                wrapper: 'define("views", function() {});, function(can) { {{{content}}} });'
            },
            dist: {
                src: ['**/*.ejs', '!node_modules/**/*.ejs', '!www-built/**/*.ejs'],
                dest: 'www/js/views.production.js'

            }
        },
        uglify: {
            //configuracion uglify
            options: {
                mangle: false,
                compress: {
                    drop_console: true
                },
                preserveComments : false
            },
            js: {
                files: [{
                    cwd: 'www-built/js/',  // ruta de nuestro javascript fuente
                    expand: true,    // ingresar a las subcarpetas
                    src: 'views.production.js',     // patrón relativo a cwd
                    dest: 'www-built/js/'  // destino de los archivos compresos
                }]
            }
        }

    });
    /*carichiamo i moduli*/
    grunt.loadNpmTasks('can-compile');
    grunt.loadNpmTasks('grunt-contrib-uglify');

    /*registriamo il task*/
    //grunt.registerTask('default', ['cancompile', 'uglify']);
    grunt.registerTask('default', ['cancompile']);
};

then first i run the grunt task and it work , it create a views.production.js into www-built directory.

then i run from terminal

node tools/r.js -o tools/build.js

and it's, but when i test the production files i got this error :

GET http://local.bst.prod/js/app/timeline/sidebar/bookmark/views/submenuBookmark.ejs 404 (Not Found)
common.js:4 Uncaught can.view: No template or empty 
template:js/app/timeline/sidebar/bookmark/views/submenuBookmark.ejs

what do i made wrong? thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.