Browse Source

add js extensions

better-aggressive
Rich Harris 9 years ago
parent
commit
e111c5d8dc
  1. 24
      src/Bundle.js
  2. 4
      src/ExternalModule.js
  3. 16
      src/Module.js
  4. 6
      src/Statement.js
  5. 2
      src/ast/attachScopes.js
  6. 4
      src/finalisers/amd.js
  7. 2
      src/finalisers/cjs.js
  8. 4
      src/finalisers/iife.js
  9. 10
      src/finalisers/index.js
  10. 4
      src/finalisers/umd.js
  11. 10
      src/rollup.js
  12. 4
      src/utils/defaults.js
  13. 2
      src/utils/fs.js
  14. 2
      src/utils/getExportMode.js
  15. 2
      src/utils/makeLegalIdentifier.js

24
src/Bundle.js

@ -1,17 +1,17 @@
import Promise from 'es6-promise/lib/es6-promise/promise'; import Promise from 'es6-promise/lib/es6-promise/promise';
import MagicString from 'magic-string'; import MagicString from 'magic-string';
import first from './utils/first'; import first from './utils/first.js';
import { blank, keys } from './utils/object'; import { blank, keys } from './utils/object.js';
import Module from './Module'; import Module from './Module.js';
import ExternalModule from './ExternalModule'; import ExternalModule from './ExternalModule.js';
import finalisers from './finalisers/index'; import finalisers from './finalisers/index.js';
import ensureArray from './utils/ensureArray'; import ensureArray from './utils/ensureArray.js';
import { load, onwarn, resolveId } from './utils/defaults'; import { load, onwarn, resolveId } from './utils/defaults.js';
import getExportMode from './utils/getExportMode'; import getExportMode from './utils/getExportMode.js';
import getIndentString from './utils/getIndentString'; import getIndentString from './utils/getIndentString.js';
import { unixizePath } from './utils/normalizePlatform'; import { unixizePath } from './utils/normalizePlatform.js';
import transform from './utils/transform'; import transform from './utils/transform.js';
import collapseSourcemaps from './utils/collapseSourcemaps'; import collapseSourcemaps from './utils/collapseSourcemaps.js';
export default class Bundle { export default class Bundle {
constructor ( options ) { constructor ( options ) {

4
src/ExternalModule.js

@ -1,5 +1,5 @@
import { blank } from './utils/object'; import { blank } from './utils/object.js';
import makeLegalIdentifier from './utils/makeLegalIdentifier'; import makeLegalIdentifier from './utils/makeLegalIdentifier.js';
class ExternalDeclaration { class ExternalDeclaration {
constructor ( module, name ) { constructor ( module, name ) {

16
src/Module.js

@ -1,12 +1,12 @@
import { parse } from 'acorn/src/index'; import { parse } from 'acorn/src/index';
import MagicString from 'magic-string'; import MagicString from 'magic-string';
import { walk } from 'estree-walker'; import { walk } from 'estree-walker';
import Statement from './Statement'; import Statement from './Statement.js';
import { blank, keys } from './utils/object'; import { blank, keys } from './utils/object.js';
import { basename, extname } from './utils/path'; import { basename, extname } from './utils/path.js';
import getLocation from './utils/getLocation'; import getLocation from './utils/getLocation.js';
import makeLegalIdentifier from './utils/makeLegalIdentifier'; import makeLegalIdentifier from './utils/makeLegalIdentifier.js';
import SOURCEMAPPING_URL from './utils/sourceMappingURL'; import SOURCEMAPPING_URL from './utils/sourceMappingURL.js';
class SyntheticDefaultDeclaration { class SyntheticDefaultDeclaration {
constructor ( node, statement, name ) { constructor ( node, statement, name ) {
@ -176,7 +176,7 @@ export default class Module {
const node = statement.node; const node = statement.node;
const source = node.source && node.source.value; const source = node.source && node.source.value;
// export { name } from './other' // export { name } from './other.js'
if ( source ) { if ( source ) {
if ( !~this.dependencies.indexOf( source ) ) this.dependencies.push( source ); if ( !~this.dependencies.indexOf( source ) ) this.dependencies.push( source );
@ -697,7 +697,7 @@ export default class Module {
} }
traceExport ( name, importer ) { traceExport ( name, importer ) {
// export { foo } from './other' // export { foo } from './other.js'
const reexportDeclaration = this.reexports[ name ]; const reexportDeclaration = this.reexports[ name ];
if ( reexportDeclaration ) { if ( reexportDeclaration ) {
return reexportDeclaration.module.traceExport( reexportDeclaration.localName, this ); return reexportDeclaration.module.traceExport( reexportDeclaration.localName, this );

6
src/Statement.js

@ -1,7 +1,7 @@
import { walk } from 'estree-walker'; import { walk } from 'estree-walker';
import Scope from './ast/Scope'; import Scope from './ast/Scope.js';
import attachScopes from './ast/attachScopes'; import attachScopes from './ast/attachScopes.js';
import getLocation from './utils/getLocation'; import getLocation from './utils/getLocation.js';
const modifierNodes = { const modifierNodes = {
AssignmentExpression: 'left', AssignmentExpression: 'left',

2
src/ast/attachScopes.js

@ -1,5 +1,5 @@
import { walk } from 'estree-walker'; import { walk } from 'estree-walker';
import Scope from './Scope'; import Scope from './Scope.js';
const blockDeclarations = { const blockDeclarations = {
'const': true, 'const': true,

4
src/finalisers/amd.js

@ -1,6 +1,6 @@
import { getName, quoteId } from '../utils/map-helpers'; import { getName, quoteId } from '../utils/map-helpers';
import getInteropBlock from './shared/getInteropBlock'; import getInteropBlock from './shared/getInteropBlock.js';
import getExportBlock from './shared/getExportBlock'; import getExportBlock from './shared/getExportBlock.js';
export default function amd ( bundle, magicString, { exportMode, indentString }, options ) { export default function amd ( bundle, magicString, { exportMode, indentString }, options ) {
let deps = bundle.externalModules.map( quoteId ); let deps = bundle.externalModules.map( quoteId );

2
src/finalisers/cjs.js

@ -1,4 +1,4 @@
import getExportBlock from './shared/getExportBlock'; import getExportBlock from './shared/getExportBlock.js';
export default function cjs ( bundle, magicString, { exportMode }, options ) { export default function cjs ( bundle, magicString, { exportMode }, options ) {
let intro = options.useStrict === false ? `` : `'use strict';\n\n`; let intro = options.useStrict === false ? `` : `'use strict';\n\n`;

4
src/finalisers/iife.js

@ -1,7 +1,7 @@
import { blank } from '../utils/object'; import { blank } from '../utils/object';
import { getName } from '../utils/map-helpers'; import { getName } from '../utils/map-helpers';
import getInteropBlock from './shared/getInteropBlock'; import getInteropBlock from './shared/getInteropBlock.js';
import getExportBlock from './shared/getExportBlock'; import getExportBlock from './shared/getExportBlock.js';
export default function iife ( bundle, magicString, { exportMode, indentString }, options ) { export default function iife ( bundle, magicString, { exportMode, indentString }, options ) {
const globalNames = options.globals || blank(); const globalNames = options.globals || blank();

10
src/finalisers/index.js

@ -1,7 +1,7 @@
import amd from './amd'; import amd from './amd.js';
import cjs from './cjs'; import cjs from './cjs.js';
import es6 from './es6'; import es6 from './es6.js';
import iife from './iife'; import iife from './iife.js';
import umd from './umd'; import umd from './umd.js';
export default { amd, cjs, es6, iife, umd }; export default { amd, cjs, es6, iife, umd };

4
src/finalisers/umd.js

@ -1,7 +1,7 @@
import { blank } from '../utils/object'; import { blank } from '../utils/object';
import { getName, quoteId, req } from '../utils/map-helpers'; import { getName, quoteId, req } from '../utils/map-helpers';
import getInteropBlock from './shared/getInteropBlock'; import getInteropBlock from './shared/getInteropBlock.js';
import getExportBlock from './shared/getExportBlock'; import getExportBlock from './shared/getExportBlock.js';
export default function umd ( bundle, magicString, { exportMode, indentString }, options ) { export default function umd ( bundle, magicString, { exportMode, indentString }, options ) {
if ( exportMode !== 'none' && !options.moduleName ) { if ( exportMode !== 'none' && !options.moduleName ) {

10
src/rollup.js

@ -1,8 +1,8 @@
import { basename } from './utils/path'; import { basename } from './utils/path.js';
import { writeFile } from './utils/fs'; import { writeFile } from './utils/fs.js';
import { keys } from './utils/object'; import { keys } from './utils/object.js';
import SOURCEMAPPING_URL from './utils/sourceMappingURL'; import SOURCEMAPPING_URL from './utils/sourceMappingURL.js';
import Bundle from './Bundle'; import Bundle from './Bundle.js';
export const VERSION = '<@VERSION@>'; export const VERSION = '<@VERSION@>';

4
src/utils/defaults.js

@ -1,5 +1,5 @@
import { readFileSync } from './fs'; import { readFileSync } from './fs.js';
import { dirname, extname, isAbsolute, resolve } from './path'; import { dirname, extname, isAbsolute, resolve } from './path.js';
export function load ( id ) { export function load ( id ) {
return readFileSync( id, 'utf-8' ); return readFileSync( id, 'utf-8' );

2
src/utils/fs.js

@ -1,6 +1,6 @@
import Promise from 'es6-promise/lib/es6-promise/promise'; import Promise from 'es6-promise/lib/es6-promise/promise';
import * as fs from 'fs'; import * as fs from 'fs';
import { dirname } from './path'; import { dirname } from './path.js';
function mkdirpath ( path ) { function mkdirpath ( path ) {
const dir = dirname( path ); const dir = dirname( path );

2
src/utils/getExportMode.js

@ -1,4 +1,4 @@
import { keys } from './object'; import { keys } from './object.js';
function badExports ( option, keys ) { function badExports ( option, keys ) {
throw new Error( `'${option}' was specified for options.exports, but entry module has following exports: ${keys.join(', ')}` ); throw new Error( `'${option}' was specified for options.exports, but entry module has following exports: ${keys.join(', ')}` );

2
src/utils/makeLegalIdentifier.js

@ -1,4 +1,4 @@
import { blank } from './object'; import { blank } from './object.js';
const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public'.split( ' ' ); const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public'.split( ' ' );
const builtins = 'Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl'.split( ' ' ); const builtins = 'Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl'.split( ' ' );

Loading…
Cancel
Save