Browse Source

linting

contingency-plan
Rich-Harris 10 years ago
parent
commit
ba3f0c6c5f
  1. 8
      .jshintrc
  2. 10
      CHANGELOG.md
  3. 13
      src/Bundle/index.js
  4. 10
      src/ast/analyse.js
  5. 2
      src/finalisers/umd.js
  6. 6
      src/utils/sanitize.js

8
.jshintrc

@ -0,0 +1,8 @@
{
"esnext": true,
"undef": true,
"unused": true,
"globals": {
"process": true
}
}

10
CHANGELOG.md

@ -0,0 +1,10 @@
# rollup changelog
## 0.2.0
* First release capable of doing anything useful
* Still lots of basic functionality missing
## 0.1.0
* Initial experiment

13
src/Bundle/index.js

@ -1,9 +1,8 @@
import { resolve, sep } from 'path';
import { resolve } from 'path';
import { readFile } from 'sander';
import MagicString from 'magic-string';
import { keys, has } from '../utils/object';
import { sequence } from '../utils/promise';
import sanitize from '../utils/sanitize';
import Module from '../Module/index';
import finalisers from '../finalisers/index';
import replaceIdentifiers from '../utils/replaceIdentifiers';
@ -16,7 +15,6 @@ export default class Bundle {
this.modulePromises = {};
this.modules = {};
this.modulesArray = [];
// this will store the top-level AST nodes we import
this.body = [];
@ -38,16 +36,7 @@ export default class Bundle {
bundle: this
});
//const bindingNames = bundle.getBindingNamesFor( module );
// we need to ensure that this module's top-level
// declarations don't conflict with the bundle so far
module.definedNames.forEach( name => {
});
this.modules[ path ] = module;
this.modulesArray.push( module );
return module;
});
}

10
src/ast/analyse.js

@ -2,16 +2,8 @@ import walk from './walk';
import Scope from './Scope';
import { getName } from '../utils/map-helpers';
function isStatement ( node, parent ) {
return node.type === 'ExportDefaultDeclaration' ||
node.type === 'ExpressionStatement' ||
node.type === 'VariableDeclaration' ||
node.type === 'FunctionDeclaration'; // TODO or any of the other various statement-ish things it could be
}
export default function analyse ( ast, magicString, module ) {
let scope = new Scope();
let topLevelStatements = [];
let currentTopLevelStatement;
function addToScope ( declarator ) {
@ -51,7 +43,7 @@ export default function analyse ( ast, magicString, module ) {
currentTopLevelStatement = statement; // so we can attach scoping info
walk( statement, {
enter ( node, parent ) {
enter ( node ) {
let newScope;
magicString.addSourcemapLocation( node.start );

2
src/finalisers/umd.js

@ -13,7 +13,7 @@ export default function umd ( bundle, magicString, options ) {
const exports = bundle.entryModule.exports;
const exportBlock = '\n\n' + Object.keys( exports ).map( name => {
return `exports.${name} = ${exports[name].localName};`
return `exports.${name} = ${exports[name].localName};`;
}).join( '\n' );
return magicString

6
src/utils/sanitize.js

@ -1,6 +0,0 @@
export default function sanitize ( name ) {
name = name.replace( /[^$_0-9a-zA-Z]/g, '_' );
if ( !/[$_a-zA-Z]/.test( name ) ) name = `_${name}`;
return name;
}
Loading…
Cancel
Save