Skip to content

Commit

Permalink
chore: convert to esbuild (#2579)
Browse files Browse the repository at this point in the history
* chore: convert to esbuild

* chore: convert to esbuild

* fix merge

* remove dep

* async

* done on error
  • Loading branch information
straker authored Oct 22, 2020
1 parent 8be89e3 commit c627d54
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 1,438 deletions.
43 changes: 13 additions & 30 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
var path = require('path');

/*eslint
camelcase: ["error", {"properties": "never"}]
*/
var testConfig = require('./build/test/config');

function createWebpackConfig(input, output, outputFilename = 'index.js') {
return {
devtool: false,
mode: 'development',
entry: path.resolve(__dirname, input),
output: {
filename: outputFilename,
path: path.resolve(__dirname, output)
}
};
}

module.exports = function(grunt) {
'use strict';

Expand All @@ -29,7 +15,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-parallel');
grunt.loadNpmTasks('grunt-run');
grunt.loadNpmTasks('grunt-webpack');
grunt.loadTasks('build/tasks');

var langs;
Expand Down Expand Up @@ -134,21 +119,19 @@ module.exports = function(grunt) {
dest: 'axe' + lang + '.js'
};
})
},
commons: {
src: [
'lib/commons/intro.stub',

// output of webpack directories
'tmp/commons/index.js',

'lib/commons/outro.stub'
],
dest: 'tmp/commons.js'
}
},
webpack: {
core: createWebpackConfig('lib/core/core.js', 'tmp/core', 'core.js')
esbuild: {
core: {
files: [
{
expand: true,
cwd: 'lib/core',
src: ['core.js'],
dest: 'tmp/core'
}
]
}
},
'aria-supported': {
data: {
Expand Down Expand Up @@ -359,11 +342,11 @@ module.exports = function(grunt) {
}
});

grunt.registerTask('translate', ['validate', 'webpack', 'add-locale']);
grunt.registerTask('translate', ['validate', 'esbuild', 'add-locale']);
grunt.registerTask('build', [
'clean',
'validate',
'webpack',
'esbuild',
'configure',
'babel',
'concat:engine',
Expand Down
34 changes: 34 additions & 0 deletions build/tasks/esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const { build } = require('esbuild');
const path = require('path');

module.exports = function(grunt) {
grunt.registerMultiTask(
'esbuild',
'Task to run the esbuild javascript bundler',
function() {
const done = this.async();
const files = grunt.task.current.data.files;

files.forEach(file => {
const src = Array.isArray(file.src) ? file.src : [file.src];
const dest = file.dest;

src.forEach(entry => {
const name = path.basename(entry);
if (file.cwd) {
entry = path.join(file.cwd, entry);
}

build({
entryPoints: [entry],
outfile: path.join(dest, name),
minify: false,
bundle: true
})
.then(done)
.catch(done);
});
});
}
);
};
1 change: 0 additions & 1 deletion lib/commons/intro.stub

This file was deleted.

2 changes: 0 additions & 2 deletions lib/commons/outro.stub

This file was deleted.

Loading

0 comments on commit c627d54

Please sign in to comment.