# Export to AMD Normalize Issue

**URL:** <https://forums.bitovi.com/t/export-to-amd-normalize-issue/198>\
**Category:** StealJS\
**Created:** [March 23, 2016, 6:29pm UTC](https://forums.bitovi.com/t/export-to-amd-normalize-issue/198 "2016-03-23T18:29:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![roemhildtg](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/roemhildtg/32/103_2.png) [@roemhildtg](https://forums.bitovi.com/u/roemhildtg)\
**Post date:** [March 23, 2016, 6:29pm UTC](https://forums.bitovi.com/t/export-to-amd-normalize-issue/198/1 "2016-03-23T18:29:11Z")

</div>

I’m trying to figure out how to export a set of canjs components to amd format using a build file like this one: [https://gist.github.com/roemhildtg/2a5242c196caadbc4db9#file-build-js](https://gist.github.com/roemhildtg/2a5242c196caadbc4db9#file-build-js)

What ends up happening is the template stache file is getting placed in the amd output folder, while the component.js file is getting placed in its relative directory under amd. Like this:

> <https://gist.github.com/roemhildtg/2a5242c196caadbc4db9#file-file-structure>

When I `require` the component.js file using amd, it tries to find the template.stache.js and fails.

---

<div class="post-metadata">

**Author:** ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)\
**Post date:** [May 24, 2016, 8:04am UTC](https://forums.bitovi.com/t/export-to-amd-normalize-issue/198/2 "2016-05-24T08:04:14Z")

</div>

We are facing the same problem. The stache files are not exported correctly. (?)

This is how our directory structure looks like:

```auto
/my-comp
    /dist
        /amd
            /src
                my-comp.js
            /views
                my-comp.stache.js
    /src
        my-comp.js
        /views
            my-comp.stache

```

We import the component with RequireJS like this  
```define([‘components/my-comp/dist/amd/src/my-comp’])````

But the grunt fails because it cannot find `./views/my-comp.stache`

---

<div class="post-metadata">

**Author:** ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)\
**Post date:** [May 24, 2016, 2:31pm UTC](https://forums.bitovi.com/t/export-to-amd-normalize-issue/198/3 "2016-05-24T14:31:44Z")

</div>

Also the generated views/my-comp.stache.js file has an incorrect reference to can/view/stache/mustache\_core.  
It should be can/view/mustache\_core.

```auto
define([
    'module',
    'can/view/stache',
    'can/view/stache/mustache_core'
], function (module, stache, mustacheCore) {

```

---

<div class="post-metadata">

**Author:** ![roemhildtg](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/roemhildtg/32/103_2.png) [@roemhildtg](https://forums.bitovi.com/u/roemhildtg)\
**Post date:** [May 24, 2016, 3:28pm UTC](https://forums.bitovi.com/t/export-to-amd-normalize-issue/198/4 "2016-05-24T15:28:29Z")

</div>

I had that same issue with mustache\_core. That one has a pretty easy workaround, in your requirejs config or dojoConfig you can do:

```javascript
      map: {
        '*': {
          'can/util/library': 'can/util/dojo',
          'can/view/stache/mustache_core': 'can/view/mustache_core'
        }
      },

```

As for the first issue, I hadn’t found a good fix for that either, but I guess in the meantime I just dragged the folders with the stache templates into their relative directory and merge the folders to get it working.

---

<div class="post-metadata">

**Author:** ![matthewp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/matthewp/32/77_2.png) [@matthewp](https://forums.bitovi.com/u/matthewp)\
**Post date:** [May 24, 2016, 10:10pm UTC](https://forums.bitovi.com/t/export-to-amd-normalize-issue/198/5 "2016-05-24T22:10:33Z")

</div>

Hey! Sorry to hear this, would love to help. One question

> [@jeroencornelissen](#):
>
> But the grunt fails because it cannot find ./views/my-comp.stache

Do you mean steal-tool export is failing (using a grunt task)?

---

<div class="post-metadata">

**Author:** ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)\
**Post date:** [May 25, 2016, 6:55am UTC](https://forums.bitovi.com/t/export-to-amd-normalize-issue/198/6 "2016-05-25T06:55:39Z")

</div>

@matthewp No, the grunt build where we use the exported component fails.  
Because the views directory is exported outside the src directory, it cannot find my-comp.stache.js file.

I now mannually 😓 moved the /dist/amd/views directory inside the /dist/amd/src directory and now it builds correctly.  
_(After I changed can/view/stache/mustache\_core to can/view/mustache\_core)_

---

<div class="post-metadata">

**Author:** ![roemhildtg](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/roemhildtg/32/103_2.png) [@roemhildtg](https://forums.bitovi.com/u/roemhildtg)\
**Post date:** [May 31, 2016, 7:19pm UTC](https://forums.bitovi.com/t/export-to-amd-normalize-issue/198/7 "2016-05-31T19:19:53Z")

</div>

@matthewp I’m encountering another related issue. I have several folders each with their own `template.stache` steal-tools is placing all of the stache templates in the root directory and some of them are getting overwritten on output.

Is there a solution to this problem, or should I just rename the templates to component\_name.stache?
