Skip to content

Commit 9f6d1b2

Browse files
committed
remove extensions from AMD dependencies – fixes #144
1 parent c1fc808 commit 9f6d1b2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/generators/shared/utils/getIntro.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function getIntro ( format, options, imports ) {
1313

1414
function getAmdIntro ( options, imports ) {
1515
const sourceString = imports.length ?
16-
`[ ${imports.map( declaration => `'${declaration.source.value}'` ).join( ', ' )} ], ` :
16+
`[ ${imports.map( declaration => `'${removeExtension( declaration.source.value )}'` ).join( ', ' )} ], ` :
1717
'';
1818

1919
const id = options.amd && options.amd.id;
@@ -48,7 +48,7 @@ function getUmdIntro ( options, imports ) {
4848

4949
const amdId = options.amd && options.amd.id ? `'${options.amd.id}', ` : '';
5050

51-
const amdDeps = imports.length ? `[${imports.map( declaration => `'${declaration.source.value}'` ).join( ', ')}], ` : '';
51+
const amdDeps = imports.length ? `[${imports.map( declaration => `'${removeExtension( declaration.source.value )}'` ).join( ', ')}], ` : '';
5252
const cjsDeps = imports.map( declaration => `require('${declaration.source.value}')` ).join( ', ' );
5353
const globalDeps = getGlobals( imports, options );
5454

@@ -63,3 +63,8 @@ function getUmdIntro ( options, imports ) {
6363
function paramString ( imports ) {
6464
return imports.length ? ` ${imports.map( dep => dep.name ).join( ', ' )} ` : '';
6565
}
66+
67+
function removeExtension ( file ) {
68+
const index = file.lastIndexOf( '.' );
69+
return ~index ? file.slice( 0, index ) : file;
70+
}

0 commit comments

Comments
 (0)