Browse Source

add back @btd fix for #1104

gh-786
Rich-Harris 8 years ago
parent
commit
a502f30365
  1. 4
      src/Bundle.js
  2. 13
      src/Module.js
  3. 2
      src/rollup.js
  4. 4
      src/utils/sourceMappingURL.js

4
src/Bundle.js

@ -15,7 +15,6 @@ import { mapSequence } from './utils/promise.js';
import transform from './utils/transform.js'; import transform from './utils/transform.js';
import transformBundle from './utils/transformBundle.js'; import transformBundle from './utils/transformBundle.js';
import collapseSourcemaps from './utils/collapseSourcemaps.js'; import collapseSourcemaps from './utils/collapseSourcemaps.js';
import SOURCEMAPPING_URL from './utils/sourceMappingURL.js';
import callIfFunction from './utils/callIfFunction.js'; import callIfFunction from './utils/callIfFunction.js';
import { dirname, isRelative, isAbsolute, normalize, relative, resolve } from './utils/path.js'; import { dirname, isRelative, isAbsolute, normalize, relative, resolve } from './utils/path.js';
import BundleScope from './ast/scopes/BundleScope.js'; import BundleScope from './ast/scopes/BundleScope.js';
@ -428,8 +427,7 @@ export default class Bundle {
let map = null; let map = null;
const bundleSourcemapChain = []; const bundleSourcemapChain = [];
code = transformBundle( code, this.plugins, bundleSourcemapChain, options ) code = transformBundle( code, this.plugins, bundleSourcemapChain, options );
.replace( new RegExp( `^\\/\\/# +${SOURCEMAPPING_URL}=.+\\n?`, 'gm' ), '' );
if ( options.sourceMap ) { if ( options.sourceMap ) {
timeStart( 'sourceMap' ); timeStart( 'sourceMap' );

13
src/Module.js

@ -5,7 +5,7 @@ import { assign, blank, deepClone, keys } from './utils/object.js';
import { basename, extname } from './utils/path.js'; import { basename, extname } from './utils/path.js';
import getLocation from './utils/getLocation.js'; import getLocation from './utils/getLocation.js';
import makeLegalIdentifier from './utils/makeLegalIdentifier.js'; import makeLegalIdentifier from './utils/makeLegalIdentifier.js';
import SOURCEMAPPING_URL from './utils/sourceMappingURL.js'; import { SOURCEMAPPING_URL_RE } from './utils/sourceMappingURL.js';
import error from './utils/error.js'; import error from './utils/error.js';
import relativeId from './utils/relativeId.js'; import relativeId from './utils/relativeId.js';
import { SyntheticNamespaceDeclaration } from './Declaration.js'; import { SyntheticNamespaceDeclaration } from './Declaration.js';
@ -72,11 +72,14 @@ export default class Module {
}); });
// remove existing sourceMappingURL comments // remove existing sourceMappingURL comments
const pattern = new RegExp( `^\\/\\/# +${SOURCEMAPPING_URL}=.+\\n?`, 'gm' ); this.comments = this.comments.filter(comment => {
let match; //only one line comment can contain source maps
while ( match = pattern.exec( code ) ) { const isSourceMapComment = !comment.block && SOURCEMAPPING_URL_RE.test(comment.text);
this.magicString.remove( match.index, match.index + match[0].length ); if (isSourceMapComment) {
this.magicString.remove(comment.start, comment.end );
} }
return !isSourceMapComment;
});
this.declarations = blank(); this.declarations = blank();
this.type = 'Module'; // TODO only necessary so that Scope knows this should be treated as a function scope... messy this.type = 'Module'; // TODO only necessary so that Scope knows this should be treated as a function scope... messy

2
src/rollup.js

@ -4,7 +4,7 @@ import { writeFile } from './utils/fs.js';
import { assign, keys } from './utils/object.js'; import { assign, keys } from './utils/object.js';
import { mapSequence } from './utils/promise.js'; import { mapSequence } from './utils/promise.js';
import validateKeys from './utils/validateKeys.js'; import validateKeys from './utils/validateKeys.js';
import SOURCEMAPPING_URL from './utils/sourceMappingURL.js'; import { SOURCEMAPPING_URL } from './utils/sourceMappingURL.js';
import Bundle from './Bundle.js'; import Bundle from './Bundle.js';
export const VERSION = '<@VERSION@>'; export const VERSION = '<@VERSION@>';

4
src/utils/sourceMappingURL.js

@ -3,4 +3,6 @@
let SOURCEMAPPING_URL = 'sourceMa'; let SOURCEMAPPING_URL = 'sourceMa';
SOURCEMAPPING_URL += 'ppingURL'; SOURCEMAPPING_URL += 'ppingURL';
export default SOURCEMAPPING_URL; const SOURCEMAPPING_URL_RE = new RegExp( `^#\\s+${SOURCEMAPPING_URL}=.+\\n?` );
export { SOURCEMAPPING_URL, SOURCEMAPPING_URL_RE };

Loading…
Cancel
Save