Open chadhietala opened 7 years ago
@chadhietala Where was the directory created? If it was within src/
I think an error is appropriate...
@rwjblue How does one add a directory for say Redux reducers? As of today it won't be watched and basically makes experimentation very difficult if the answer is "write a custom Broccoli thing". That is a barrier to entry that we likely need to remove.
You put files that will be used via import
only in src/utils
(e.g. not expected to be auto-resolved) or you can add a local -utils
collection in any other collection.
Also, if you want to register custom types / collections, you can add your own moduleConfiguration
in config/environment.js
.
However, this currently overrides (rather than merges with) the defaults, so it would need to be complete. We should consider a merge strategy too, since that will probably be used most often.
BTW, here is the default module configuration: https://github.com/glimmerjs/glimmer-application-pipeline/blob/master/lib/broccoli/default-module-configuration.ts
And the structure is defined in glimmer-resolver: https://github.com/glimmerjs/glimmer-resolver/blob/master/src/resolver-configuration.ts
As a regular joe userland person, I was confused by this error.
I opened an issue on glimmer-application because I wasn't sure why I couldn't add an arbitrary file to my glimmer project. There's nothing stated in the docs (as far as I could tell) that instructs me to avoid doing so.
I hit this, too. This would be a great place to mention this:
https://glimmerjs.com/guides/filesystem-layout
I don't know if this is a convention from the ember ecosystem but it makes it harder for new folks to build. The framework itself is very impressive. I was duly shocked at the performance and build size but a guide on how to import your own modules is helpful. Not knowing ember's DI this is the example I have found from @toranb:
https://github.com/glimmer-redux/glimmer-redux-example/blob/master/config/environment.js
Right now I am attempting something like the below. [edit] Turns out it can be simplified a bit more. Adding unresolved: true
also eliminates the need to have export default
, presumably if broccoli is configured to use commonjs
.
'use strict';
const merge = require('lodash.merge');
const fs = require('fs');
const defaultModuleConfigurationPath = __dirname + '/../node_modules/@glimmer/application-pipeline/lib/broccoli/default-module-configuration.ts';
const defaultModuleConfigurationString = fs.readFileSync(defaultModuleConfigurationPath, 'utf-8');
let moduleConfiguration = eval('(' + defaultModuleConfigurationString.replace('export default', '').replace(';', '') + ')');
moduleConfiguration = merge(moduleConfiguration, {
types: {
common: { definitiveCollection: 'commons' },
feature: { definitiveCollection: 'features' },
},
collections: {
common: { unresolvable: true },
feature: { unresolvable: true }
}
})
module.exports = function(environment) {
let ENV = {
modulePrefix: 'glimmer-tribescribe',
environment,
moduleConfiguration
};
return ENV;
};
If you try to add a directory to the module unification file structure it should not throw. Currently if you write some TS file and import it into the a MU directory an error is thrown: