Provide scriptExtensions option for 3.x#240
Conversation
|
Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test." |
|
Can one of the admins verify this patch? |
2 similar comments
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Thank you @supasate for the pull request. I am personally not very familiar with |
|
@slnode ok to test |
|
Is there any update on this PR? |
|
Can one of the admins verify this patch? |
|
Hi @supasate, sorry for the delay. I'll ping @davidcheung and @raymondfeng to bring this pull request into their attention. Meanwhile, if you are using |
|
I have made another PR for 2.x at #242. |
|
|
||
| // find a matching file with a supported extension like `.js` or `.coffee` | ||
| var sourceFile = fixFileExtension(jsonFile, allFiles, true); | ||
| var sourceFile = fixFileExtension(jsonFile, allFiles, true, scriptExtensions); |
There was a problem hiding this comment.
The third param onlyScriptsExportingFunction cause .js files of models will not be loaded.
Line 142 in utils.js checking typeof require.extensions['.js'] === 'function' which will be false when using jest.
There was a problem hiding this comment.
@clarkorz In Jest, we will provide options.scriptExtensions = ['.js'] and it will return when it reaches if (isPreferredExtension(filepath, scriptExtensions)) return filepath; before getting into that condition.
68378cb to
acef509
Compare
|
I've fixed the code based on @bajtos's comments on |
7c23a1f to
d68ffc6
Compare
bajtos
left a comment
There was a problem hiding this comment.
I am not familiar with 3.x/master codebase, but FWIW, the changes LGTM.
I'll leave it up to @raymondfeng or @davidcheung to give this their final approval and land it.
Backport of strongloop#240 with some simplifications for this version
Description
Provide
scriptExtensionsoption for custom loading.Due to
require.extensionsis not used by some framework (e.g.jest). So, this feature allows specifying file extensions supported by custom loaders.Related issues
strongloop/loopback#3204
Checklist