Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Directory Alias in RequireJS Modules #31

Closed
Anachron opened this issue Mar 11, 2014 · 14 comments
Closed

Support for Directory Alias in RequireJS Modules #31

Anachron opened this issue Mar 11, 2014 · 14 comments

Comments

@Anachron
Copy link

Modules like 'css!c/app/test' will throw an error, even if 'c' is defined as short path for the stylesheet directory. The app thinks c is the name of the folder instead of replacing it with the actual path set.

@Anachron
Copy link
Author

Now the CSS-is supported, but HBS are not. Also paths like

https://github.com/Anachron/satisfy/blob/master/assets/javascripts/common.coffee

  paths:
    ...
    # Folders
    'j':                                '../javascripts'
    'c':                                '../stylesheets'
    't':                                '../templates/'

https://github.com/Anachron/satisfy/blob/master/assets/javascripts/app/views/items/Todo.coffee#L5-L6

define [
    'backbone',
    'backbone.marionette',
    'jquery',
    'hbs!t/app/items/Todo',
    'css!c/app/Todo'
  ], (Backbone, Marionette, $, TodoTemplate) ->

    TodoItemView = Marionette.ItemView.extend({
      'template': TodoTemplate,

      'events': {
        'click label': "toggleDone"
      },

      toggleDone: () ->
        $(@el).find('.checkbox').toggleClass('done')

    })

work, but they still throw errors.

also the baseUrl option does currently not work with Mimosa-Require checks.
I would rather use

  baseUrl: '../'
  ...
  'paths':
    'j':                                'javascripts'
    'c':                                'stylesheets'
    't':                                'templates'

Instead of hardly changing the code, I would love to have another option to provide a simple adapter in the mimosa-config.coffee-file. Something like:

  require:
    'modules':
      'css':
        'extension': 'css'
        'check': true #Either a function or boolean (true = internal search, false = no path validation, function = custom path validation)
      'hbs':
        'extension': 'hbs'
        'check': true

Add support for various plugins and have a short list for the known ones, how to implement them 👍

@dbashford
Copy link
Owner

Afraid that doesn't make much sense. Instead of supporting it, make people write their own support?

I hope to get to this before Monday.

@Anachron
Copy link
Author

Thanks for your feedback! If you need any more information, please let me know.

@dbashford
Copy link
Owner

@Anachron could you put together a branch of satisfy where you have the require.js config the way you want it? Forget that mimosa-require gets angry with you. Just get the app working with require.js. Looking into the baseUrl thing you mention above.

@Anachron
Copy link
Author

@dbashford basically, it's like in my setup above. Set baseUrl: '..' and then for the templates and javascripts and styles, remove the ../ notation.

But if it will help you I will be glad to create a fork. But I will take a nap first 😪

@dbashford
Copy link
Owner

Working on this now. Have it fixed, but want to do a bit more to allow something closer to what you were asking for (ability to configure plugins and extensions for them). Expect it maybe tonight, possibly tomorrow.

@Anachron
Copy link
Author

Thanks, that's good News. Need any more information?

@dbashford
Copy link
Owner

Nope, I'm good. =)

@dbashford
Copy link
Owner

This is where I'll end up in terms of config. The check thing makes no sense. No reason to selectively disable.

This will require some documentation which needs to get done before the upgraded mimosa-require finds its way into mimosa. That might not happen until tomorrow. But I'll get the new mimosa-require published today.

verify:                  # settings for requirejs path verification
  enabled: true          # Whether or not to perform verification
  plugins:               # config for plugins. mimosa-require will verify plugin paths that
                         # are listed as dependencies. It does not keep track of plugins
                         # otherwise.
    css:"css"            # these are the built-in default plugins. The key is the name of the
    hbs:"hbs"            # plugin, the value before the !, and the value is the extension used
                         # for those files. If you update this setting to add a new plugin,
                         # consider opening a mimosa-require issue to make that plugin another
                         # default.

@Anachron
Copy link
Author

That's great, it's more simple and I really like it.
Will wait until you pushed it as regular mimosa tag though. 👍

@dbashford
Copy link
Owner

Pushed mimosa v2.1.20. I'll get to the docs later.

@Anachron
Copy link
Author

I am afraid this isn't fixed:

PS D:\dev\satisfy> mimosa -V
2.1.20
PS D:\dev\satisfy> mimosa watch -s
20:19:50 - Info - No Bower installs needed.
20:19:50 - Info - Watching assets
20:19:50 - Success - Wrote file public\javascripts\app.js
20:19:50 - ERROR - Dependency public\stylesheets for path alias c, inside file p
ublic\javascripts\common.js, cannot be found.
20:19:50 - ERROR - Dependency public\templates for path alias t, inside file pub
lic\javascripts\common.js, cannot be found.
20:19:50 - ERROR - Dependency /javascripts/app/models/Todo, inside file public\j
avascripts\app\collections\TodoList.js, cannot be found.
20:19:50 - ERROR - Plugin /templates/app/test.hbs, inside file public\javascript
s\app\views\TestView.js, cannot be found.
20:19:50 - ERROR - Dependency marionette, inside file public\javascripts\app\vie
ws\collections\TodoList.js, cannot be found.
20:19:50 - ERROR - Dependency /javascripts/app/views/items/TodoListItem, inside
file public\javascripts\app\views\collections\TodoList.js, cannot be found.
20:19:50 - ERROR - Plugin /templates/app/collections/TodoListTemplate.hbs, insid
e file public\javascripts\app\views\collections\TodoList.js, cannot be found.
20:19:50 - ERROR - Plugin t/app/items/Todo.hbs, inside file public\javascripts\a
pp\views\items\Todo.js, cannot be found.
20:19:50 - ERROR - Plugin c/app/Todo.css, inside file public\javascripts\app\vie
ws\items\Todo.js, cannot be found.
20:19:50 - ERROR - Plugin t/templates/app/items/TodoListItem.hbs, inside file pu
blic\javascripts\app\views\items\TodoListItem.js, cannot be found.
20:19:51 - Success - Mimosa is starting your server: server.coffee
Express server listening on port 3000 in development mode
   info  - socket.io started

I pushed the latest version of satisfy for you:
Anachron/satisfy@5d26310

There are no errors in the console. If you uncomment this:
https://github.com/Anachron/satisfy/blob/master/assets/javascripts/app.coffee#L22-L32
the app works as expected. (But still throws errors in Mimosa)

@dbashford
Copy link
Owner

I get the following errors only

16:44:25 - ERROR - Dependency /javascripts/app/models/Todo, inside file public/javascripts/app/collections/TodoList.js, cannot be found.
16:44:25 - ERROR - Dependency marionette, inside file public/javascripts/app/views/collections/TodoList.js, cannot be found.
16:44:25 - ERROR - Dependency /javascripts/app/views/items/TodoListItem, inside file public/javascripts/app/views/collections/TodoList.js, cannot be found.
16:44:25 - ERROR - Plugin /templates/app/collections/TodoListTemplate.hbs, inside file public/javascripts/app/views/collections/TodoList.js, cannot be found.
16:44:25 - ERROR - Plugin t/templates/app/items/TodoListItem.hbs, inside file public/javascripts/app/views/items/TodoListItem.js, cannot be found.

This is broken because you need to use t and not templates.

16:44:25 - ERROR - Plugin /templates/app/collections/TodoListTemplate.hbs, inside file public/javascripts/app/views/collections/TodoList.js, cannot be found.

This is broken because its just a bad path. t AND templates.

16:44:25 - ERROR - Plugin t/templates/app/items/TodoListItem.hbs, inside file public/javascripts/app/views/items/TodoListItem.js, cannot be found.

This is broken because you need to use j.

16:44:25 - ERROR - Dependency /javascripts/app/views/items/TodoListItem, inside file public/javascripts/app/views/collections/TodoList.js, cannot be found.

This is broken because, as I discussed in the issue I opened on your repo, marionette does not exist as a path.

16:44:25 - ERROR - Dependency marionette, inside file public/javascripts/app/views/collections/TodoList.js, cannot be found.

And this doesn't work because you need to use j

16:44:25 - ERROR - Dependency /javascripts/app/models/Todo, inside file public/javascripts/app/collections/TodoList.js, cannot be found.

@Anachron
Copy link
Author

Turns out I had old files that had not been cleaned in public directory. After cleaning and another compilation all works well. Thanks!
I've also fixed the path problems from the files I didn't use yet in my app.

Anachron/satisfy@4545dc9
Anachron/satisfy@a27f321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants