Commit 3f39acaf by Marijn Haverbeke

Store the whole options object in Program

So that transforms have access to other options.
parent 1fa59fbd
......@@ -7,7 +7,7 @@ export default function Program ( source, ast, transforms, options ) {
// options
this.jsx = options.jsx || 'React.createElement';
this.objectAssign = options.objectAssign;
this.options = options;
this.source = source;
this.magicString = new MagicString( source );
......
......@@ -53,10 +53,10 @@ export default class JSXOpeningElement extends Node {
if ( len === 1 ) {
before = html ? `',` : ',';
} else {
if (!this.program.objectAssign) {
if (!this.program.options.objectAssign) {
throw new CompileError( this, 'Mixed JSX attributes ending in spread requires specified objectAssign option with \'Object.assign\' or polyfill helper.' );
}
before = html ? `', ${this.program.objectAssign}({},` : `, ${this.program.objectAssign}({},`;
before = html ? `', ${this.program.options.objectAssign}({},` : `, ${this.program.objectAssign}({},`;
after = ')';
}
} else {
......
......@@ -21,7 +21,7 @@ export default class ObjectExpression extends Node {
}
if ( spreadPropertyCount ) {
if ( !this.program.objectAssign ) {
if ( !this.program.options.objectAssign ) {
throw new CompileError( this, 'Object spread operator requires specified objectAssign option with \'Object.assign\' or polyfill helper.' );
}
// enclose run of non-spread properties in curlies
......@@ -47,7 +47,7 @@ export default class ObjectExpression extends Node {
// wrap the whole thing in Object.assign
firstPropertyStart = this.properties[0].start;
code.overwrite( this.start, firstPropertyStart, `${this.program.objectAssign}({}, `);
code.overwrite( this.start, firstPropertyStart, `${this.program.options.objectAssign}({}, `);
code.overwrite( this.properties[ this.properties.length - 1 ].end, this.end, ')' );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment