Skip to content

Commit

Permalink
fix(simport) namespaced imports
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Jan 23, 2021
1 parent dcc71c4 commit e66c06c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
},
"license": "MIT",
"devDependencies": {
"@cloudcmd/stub": "^3.3.0",
"c8": "^7.3.5",
"coveralls": "^3.0.2",
"eslint": "^7.0.0",
Expand Down
3 changes: 2 additions & 1 deletion simport.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ module.exports.createSimport = (url) => {
let imported;
let error;

if (/^[a-z]/.test(name))
if (/^[@a-z]/.test(name)) {
imported = await tryNoExt(resolved);
}

if (!imported) {
[error, imported] = await tryToCatch(tryJS, resolved);
Expand Down
10 changes: 10 additions & 0 deletions simport.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,13 @@ test('simport: absolute', async (t) => {
t.end();
});

test('simport: external', async (t) => {
const {__filename} = createCommons(url);
const simport = createSimport(__filename);

const [error] = await tryToCatch(simport, '@cloudcmd/stub');

t.notOk(error);
t.end();
});

0 comments on commit e66c06c

Please sign in to comment.