Browse Source

use relative ID for more readable message

legacy-quote-reserved-properties
Rich-Harris 8 years ago
parent
commit
4eae8da80d
  1. 3
      src/ast/nodes/ThisExpression.js
  2. 1
      test/function/warn-on-top-level-this/_config.js

3
src/ast/nodes/ThisExpression.js

@ -1,5 +1,6 @@
import Node from '../Node.js';
import getLocation from '../../utils/getLocation.js';
import relativeId from '../../utils/relativeId.js';
const warning = `The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten. See https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined for more information`;
@ -11,7 +12,7 @@ export default class ThisExpression extends Node {
this.alias = this.module.context;
if ( this.alias === 'undefined' ) {
const { line, column } = getLocation( this.module.code, this.start );
const detail = `${this.module.id} (${line}:${column + 1})`; // use one-based column number convention
const detail = `${relativeId( this.module.id )} (${line}:${column + 1})`; // use one-based column number convention
this.module.bundle.onwarn( `${detail} ${warning}` );
}
}

1
test/function/warn-on-top-level-this/_config.js

@ -1,7 +1,6 @@
const assert = require( 'assert' );
module.exports = {
solo: true,
description: 'warns on top-level this (#770)',
warnings: warnings => {
assert.deepEqual( warnings, [

Loading…
Cancel
Save