How to declare global resources for Value Converter?


#1

Unfortunately, the guide here: http://aurelia.io/docs/binding/value-converters#signalable-value-converters does not have example for it. This is my project structure:

I have tried (each with and without leading ./ ):

“./app/converters/dateOnly”
"./app/converters/date-only"
"./app/converters/DateOnly"
"./converters/dateOnly"
"./converters/date-only"
"./converters/DateOnly"

All causes error: Error: Unable to find module with ID: ./converters/DateOnly

How should the resource path be?


#2

Solved, it’s:

aurelia
    .use
    .globalResources(PLATFORM.moduleName("app/converters/DateOnly"));

It should be mentioned in the documentation. Nowhere in the above link and this http://aurelia.io/docs/fundamentals/app-configuration-and-startup#making-resources-global say about wrapping it in PLATFORM.moduleName.


#3

Probably because it’s only really required for webpack, at least that’s my understanding.


#4

I see. Sorry I was mainly a back-end developer so I didn’t really understand about Webpack or Aurelia CLI. Probably should still mention that in the doc?


#5

Yes, not sure if it is in the main docs or one of the docs for the webpack plugins


#6

@datvm all documentation is generated from markdown files which are part of the respective repo.
So looking at your link you’ll see that its pointing to docs/binding which means it points to this MD file https://github.com/aurelia/binding/blob/master/doc/article/en-US/binding-value-converters.md.

If you struggled and think its a good opportunity to add some notes there, why not create a PR on said file so it gets into the docs once approved and rebuilt?


#7

Oh wonderful! I didn’t know that. Will do. I am kinda new though so not sure if it will be helpful.