Skip to content

Commit

Permalink
Merge pull request #206 from sveltejs/gh-144
Browse files Browse the repository at this point in the history
remove extensions from AMD dependencies
  • Loading branch information
Rich-Harris authored Dec 17, 2016
2 parents 298bfb8 + 9f6d1b2 commit 1c3f144
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/generators/shared/utils/getIntro.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function getIntro ( format, options, imports ) {

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

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

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

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

Expand All @@ -63,3 +63,8 @@ function getUmdIntro ( options, imports ) {
function paramString ( imports ) {
return imports.length ? ` ${imports.map( dep => dep.name ).join( ', ' )} ` : '';
}

function removeExtension ( file ) {
const index = file.lastIndexOf( '.' );
return ~index ? file.slice( 0, index ) : file;
}

0 comments on commit 1c3f144

Please sign in to comment.