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

Unable to load proxied external npm dependencies #372

Merged
merged 1 commit into from
Dec 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/oc-external-dependencies-handler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* bundled by webPack but instead remain requested by the resulting bundle.
* For more info http://webpack.github.io/docs/configuration.html#externals
*
*/
*/

const coreModules = require('builtin-modules');
const strings = require('oc-templates-messages');
Expand All @@ -24,7 +24,7 @@ module.exports = dependencies => {
(context, req, callback) => {
if (matcher.test(req)) {
let dependencyName = req;
if (/\//g.test(dependencyName)) {
if (/^(?!@).*\//g.test(dependencyName)) {
dependencyName = dependencyName.substring(
0,
dependencyName.indexOf('/')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,15 @@ test('The handler matcher should correctly match aganinst not valid modules', ()
expect(handlerMatcher.test('./myModule.json')).toBe(false);
expect(handlerMatcher.test('./myModule.js')).toBe(false);
});

test('Module declared with @org_namespace/module_name in the package is also allowed (proxied npm registry)', done => {
const handler = externalDependenciesHandler({
'@org/proxied-lodash': '4.17.4'
});
const handlerFunction = handler[0];

handlerFunction(null, '@org/proxied-lodash', err => {
expect(err).toBeUndefined();
done();
});
});