Skip to content

Commit

Permalink
Update babel and webpack
Browse files Browse the repository at this point in the history
Remove wildcard and require tests since the library has a default export and
that's what should be used for browser code.
  • Loading branch information
mohd-akram committed Sep 20, 2023
1 parent ce1f2ab commit 2fce11e
Show file tree
Hide file tree
Showing 10 changed files with 6,441 additions and 18,063 deletions.
26 changes: 23 additions & 3 deletions Gruntfile.js
Expand Up @@ -41,10 +41,16 @@ module.exports = function (grunt) {
babel: {
options: {
sourceMaps: 'inline',
loose: ['es6.modules'],
auxiliaryCommentBefore: 'istanbul ignore next',
},
cjs: {
options: {
plugins: [
[
'@babel/plugin-transform-modules-commonjs',
{ importInterop: 'none' },
],
],
},
files: [
{
cwd: 'lib/',
Expand All @@ -57,11 +63,25 @@ module.exports = function (grunt) {
},
webpack: {
options: {
mode: 'production',
optimization: { minimize: false },
target: 'web',
context: __dirname,
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
use: ['source-map-loader'],
},
],
},
output: {
path: 'dist/',
path: __dirname + '/dist/',
library: 'Handlebars',
libraryTarget: 'umd',
libraryExport: 'default',
globalObject: 'this',
},
},
handlebars: {
Expand Down
12 changes: 6 additions & 6 deletions lib/precompiler.js
@@ -1,12 +1,12 @@
/* eslint-env node */
/* eslint-disable no-console */
import Async from 'neo-async';
import fs from 'fs';
import * as Handlebars from './handlebars';
import * as fs from 'fs';
import Handlebars from './handlebars';
import { basename } from 'path';
import { SourceMapConsumer, SourceNode } from 'source-map';

module.exports.loadTemplates = function (opts, callback) {
export function loadTemplates(opts, callback) {
loadStrings(opts, function (err, strings) {
if (err) {
callback(err);
Expand All @@ -21,7 +21,7 @@ module.exports.loadTemplates = function (opts, callback) {
});
}
});
};
}

function loadStrings(opts, callback) {
let strings = arrayCast(opts.string),
Expand Down Expand Up @@ -153,7 +153,7 @@ function loadFiles(opts, callback) {
);
}

module.exports.cli = function (opts) {
export function cli(opts) {
if (opts.version) {
console.log(Handlebars.VERSION);
return;
Expand Down Expand Up @@ -300,7 +300,7 @@ module.exports.cli = function (opts) {
} else {
console.log(output);
}
};
}

function arrayCast(value) {
value = value != null ? value : [];
Expand Down

0 comments on commit 2fce11e

Please sign in to comment.