Closed prewk closed 10 years ago
I'll answer my question myself: Yes it is, the error message doesn't accurately describe the file name required. I re-arranged all the relative requires to a js file higher up in the file hierarchy and my problem was solved.
It's pretty easy to run into weird problems with require
paths etc, but since I can't present at better test case I'll just leave it.
I'm still wondering about require('../something.js)
, though. Is it supposed to work?
@wryk Yeah I'd like to respect this but it becomes ridiculous in a large project, which utilizes multiple small components but in itself is a large component never meant for publishing.
Isn't it fairly common to use filenames matching "class names", even in JS?
But I'm sure there's lots of arguments back and forth about this I'm not aware of. I just hope I won't get forced to use spinal-case everywhere in the future.
require('../something.js)
wasn't mean above the root folder, it's for something like this:
app.js
some-module/controllers/
some-module/controllers/SomeController.js
some-module/module.js
To be able to use SomeController.js
I need to require module.js
in it, and that's where ../module.js
came from.
It's not above the root folder, but maybe it's not a very clever way to work with anyway.
I moved all the requires to the app.js
in the above example instead to solve my problems. Not very elegant but it works.
we ran into issues with camelcased stuff so we decided to keep them all lower case. makes stuff more platform compatible anyways if everythign is lowercased. it's just easier to implement, though i wouldn't mind adding camelcase back with a lot of tests on all platforms.
can you provide a test case for require('../something.js')
? that stuff should work
I see, thanks!
Yeah, I should be able to isolate and reproduce it. I've been fighting a couple of days with weird behaviors in component build
vs using the example code for component-builder2
(which I had to change a lot due to a non-existing end
method and when I finally got it to build, it complained about using require('./foo/bar/MyController.js');
, which built fine with component build
.. but that's for another test case and/or repo :grinning:)
I'll drop a test case here ASAP.
Alright, the problem seems to happen if I'm requiring a path including a camelCased directory. If that's normal then I guess that's my issue.
This seems to work:
"src/spinal-case/module.js",
"src/spinal-case/controllers/AlsoCamelCaseController.js",
While this doesn't:
"src/camelCase/module.js",
"src/camelCase/controllers/CamelCaseController.js",
(Both controllers use require('../module.js');
)
If you want to reproduce the error, clone https://github.com/prewk/component-problem.git and try out component build
in it:
build : resolved in 9ms
build : files in 9ms
error : could not resolve "../module.js" from "component-problem"'s file "src/camelCase/controllers/CamelCaseController.js"
Since camelCasing clouds the error-report, I'll close this.
I'd like to get camelCase back in. I stuck with Component v0.18.0 on my projects just because of that
there is a open PR https://github.com/componentjs/builder2.js/pull/85 I will check it soon
I'm trying to
require('./controllers/SiteListController.js');
but it gives me the following error:error : could not resolve "./controllers/sitelistcontroller.js"
.Is the all-lowercase enforced on relative paths? I can understand that component names etc should be lowercase, but isn't it possible to have any capital letters in any file anywhere when using require?
Pretty harsh.
Also, it seems
require('../something.js')
doesn't work as it did in a (much) earlier version of Component(1). Is this intended?Thanks!