diff --git a/packages/less/Gruntfile.js b/packages/less/Gruntfile.js index 061ccda86..8d30d93a7 100644 --- a/packages/less/Gruntfile.js +++ b/packages/less/Gruntfile.js @@ -190,9 +190,10 @@ module.exports = function(grunt) { // Handle async / await in Rollup build for tests // Remove this when Node 6 is no longer supported for the build/test process const nodeVersion = semver.major(process.versions.node); + const tsNodeRuntime = path.resolve(path.join('node_modules', '.bin', 'ts-node')); let scriptRuntime = 'node'; if (nodeVersion < 8) { - scriptRuntime = path.resolve(path.join('node_modules', '.bin', 'ts-node')); + scriptRuntime = tsNodeRuntime; } // Project configuration. @@ -228,7 +229,10 @@ module.exports = function(grunt) { command: scriptRuntime + " build/rollup.js --browser --out=./tmp/browser/less.min.js" }, test: { - command: "node test/index.js" + command: [ + tsNodeRuntime + " test/test-es6.ts", + "node test/index.js" + ].join(' && ') }, generatebrowser: { command: 'node test/browser/generator/generate.js' diff --git a/packages/less/src/less/index.js b/packages/less/src/less/index.js index da50b1841..574d5da64 100644 --- a/packages/less/src/less/index.js +++ b/packages/less/src/less/index.js @@ -88,5 +88,14 @@ export default (environment, fileManagers) => { } } + /** + * Some of the functions assume a `this` context of the API object, + * which causes it to fail when wrapped for ES6 imports. + * + * An assumed `this` should be removed in the future. + */ + initial.parse = initial.parse.bind(api); + initial.render = initial.render.bind(api); + return api; };