From 9f6d1b2d9e0cc3790c421407040efd02b99d3be6 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sat, 17 Dec 2016 16:42:23 -0500 Subject: [PATCH] =?UTF-8?q?remove=20extensions=20from=20AMD=20dependencies?= =?UTF-8?q?=20=E2=80=93=20fixes=20#144?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/generators/shared/utils/getIntro.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/generators/shared/utils/getIntro.js b/src/generators/shared/utils/getIntro.js index ce0f5525b8a4..3a11c1d2370a 100644 --- a/src/generators/shared/utils/getIntro.js +++ b/src/generators/shared/utils/getIntro.js @@ -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; @@ -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 ); @@ -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; +}