File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { SourceType } from 'coffee-lex' ;
22import { PatchOptions } from '../../../patchers/types' ;
33
4+ import ExportAllDeclarationPatcher from './ExportAllDeclarationPatcher' ;
5+ import ExportBindingsDeclarationPatcher from './ExportBindingsDeclarationPatcher' ;
6+ import ImportDeclarationPatcher from './ImportDeclarationPatcher' ;
47import InterpolatedPatcher from './InterpolatedPatcher' ;
58
69/**
@@ -38,6 +41,16 @@ export default class StringPatcher extends InterpolatedPatcher {
3841 }
3942
4043 shouldBecomeTemplateLiteral ( ) : boolean {
44+ if (
45+ ( this . parent instanceof ImportDeclarationPatcher ||
46+ this . parent instanceof ExportAllDeclarationPatcher ||
47+ this . parent instanceof ExportBindingsDeclarationPatcher ) &&
48+ this . parent . source === this
49+ ) {
50+ // Import sources should never be template literals.
51+ return false ;
52+ }
53+
4154 return this . expressions . length > 0 || this . node . raw . indexOf ( '\n' ) > - 1 ;
4255 }
4356}
Original file line number Diff line number Diff line change @@ -227,4 +227,25 @@ describe('imports', () => {
227227 `
228228 ) ;
229229 } ) ;
230+
231+ it ( 'does not convert an import source to a template literal (#1368)' , ( ) => {
232+ check (
233+ `
234+ import """stupid file name
235+ """
236+ export * from """another stupid file name
237+ """
238+ export { a } from """a third stupid file name
239+ """
240+ ` ,
241+ `
242+ import "stupid file name\\
243+ ";
244+ export * from "another stupid file name\\
245+ ";
246+ export { a } from "a third stupid file name\\
247+ ";
248+ `
249+ ) ;
250+ } ) ;
230251} ) ;
You can’t perform that action at this time.
0 commit comments