Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to esm #26

Draft
wants to merge 47 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
94d2439
Allow mocha running for mjs
adrinr Dec 3, 2024
657466e
Convert uuid to mjs
adrinr Dec 3, 2024
c2cce12
Migrate array and match tests
adrinr Dec 3, 2024
879c1ca
Migrate more tests
adrinr Dec 3, 2024
30d3271
Migrate more tests
adrinr Dec 3, 2024
eb075d2
Migrate more tests
adrinr Dec 3, 2024
997ac36
Migrate more tests
adrinr Dec 3, 2024
b9da189
Migrate more tests
adrinr Dec 3, 2024
15c26c1
Lint
adrinr Dec 3, 2024
b534380
lint
adrinr Dec 3, 2024
18165dd
Remove index.js
adrinr Dec 3, 2024
275949e
Remove unnecessary "integration" tests
adrinr Dec 3, 2024
4406a27
Update lib/index
adrinr Dec 3, 2024
d0d041b
Convert uuid
adrinr Dec 3, 2024
8623487
More migrations
adrinr Dec 3, 2024
b9d8538
Migrate "code"
adrinr Dec 3, 2024
24ace03
Convert "comparison"
adrinr Dec 3, 2024
4f92a79
Fix linting
adrinr Dec 3, 2024
6cfdc1f
Convert number
adrinr Dec 3, 2024
81d68f8
Migrate i18n
adrinr Dec 3, 2024
9a2c3b1
Migrate html
adrinr Dec 3, 2024
7ae8256
More conversions
adrinr Dec 3, 2024
51ad523
More conversions
adrinr Dec 3, 2024
a22f487
Migrate and fix math
adrinr Dec 3, 2024
fccb815
Remove sinon
adrinr Dec 3, 2024
78a43f1
More conversions
adrinr Dec 3, 2024
0ddfa00
Migrate url
adrinr Dec 3, 2024
2a1f618
Migrate utils/index
adrinr Dec 3, 2024
ed65721
More conversions
adrinr Dec 3, 2024
be1cda5
More conversions
adrinr Dec 3, 2024
434bbd6
Migrate html
adrinr Dec 4, 2024
620af13
More conversions
adrinr Dec 4, 2024
2dad80f
More conversions
adrinr Dec 4, 2024
86f9002
More conversions
adrinr Dec 4, 2024
50b09cf
Migrate inverse
adrinr Dec 4, 2024
1b996d3
Convert options
adrinr Dec 4, 2024
564f0a2
Convert indexOf
adrinr Dec 4, 2024
922d0d6
Convert identity
adrinr Dec 4, 2024
f87949f
More conversions
adrinr Dec 4, 2024
4c7e859
More conversions
adrinr Dec 4, 2024
90d5b96
Migrate isString
adrinr Dec 4, 2024
c27570a
Final conversion
adrinr Dec 4, 2024
3233c20
Rename back from mjs to js
adrinr Dec 4, 2024
7dc5a25
Undo
adrinr Dec 4, 2024
e277fa9
Lint
adrinr Dec 4, 2024
fa4a6e4
Merge branch 'master' into convert-to-esm
adrinr Dec 4, 2024
4f9f81f
Support es5
adrinr Dec 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename back from mjs to js
  • Loading branch information
adrinr committed Dec 4, 2024
commit 3233c20ef3f8d6be43105afc579ef88d77a6de34
5 changes: 2 additions & 3 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extension": [
"js",
"mjs"
"js"
],
"spec": "test/**/*.{js,mjs}"
"spec": "test/**/*.js"
}
4 changes: 2 additions & 2 deletions index.mjs → index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

'use strict';

import lib from './lib/index.mjs';
import lib from './lib/index.js';
// TODO: import only when required
import Handlebars from 'handlebars';

Expand Down Expand Up @@ -71,5 +71,5 @@ export const string = exportGroup(lib.string);
export const url = exportGroup(lib.url);
export const uuid = exportGroup(lib.uuid);

import * as _utils from './lib/utils/index.mjs';
import * as _utils from './lib/utils/index.js';
export const utils = _utils;
4 changes: 2 additions & 2 deletions lib/array.mjs → lib/array.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

import * as util from './utils/index.mjs';
import * as util from './utils/index.js';
import getValue from 'get-value';
import createFrame from './utils/createFrame.mjs';
import createFrame from './utils/createFrame.js';

/**
* Returns all of the items in an array after the specified index.
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions lib/collection.mjs → lib/collection.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

import { isOptions, fn, isObject } from './utils/index.mjs';
import { forOwn } from './object.mjs';
import { forEach } from './array.mjs';
import value from './utils/value.mjs';
import { isOptions, fn, isObject } from './utils/index.js';
import { forOwn } from './object.js';
import { forEach } from './array.js';
import value from './utils/value.js';

/**
* Inline, subexpression, or block helper that returns true (or the block)
Expand Down
6 changes: 3 additions & 3 deletions lib/comparison.mjs → lib/comparison.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import has from 'has-value';

import * as util from './utils/index.mjs';
import falsey from './utils/falsey.mjs';
import isOdd from './utils/odd.mjs';
import * as util from './utils/index.js';
import falsey from './utils/falsey.js';
import isOdd from './utils/odd.js';

/**
* Helper that renders the block if **both** of the given values
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/html.mjs → lib/html.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

import { extname, posix } from 'path';
import { arrayify } from './utils/index.mjs';
import { parseAttributes, sanitize as htmlSanitize } from './utils/html.mjs';
import { arrayify } from './utils/index.js';
import { parseAttributes, sanitize as htmlSanitize } from './utils/html.js';
var parseAttr = parseAttributes;

import htmlTag from 'html-tag';
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n.mjs → lib/i18n.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import * as utils from './utils/index.mjs';
import * as utils from './utils/index.js';
import getValue from 'get-value';

/**
Expand Down
39 changes: 39 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';

import * as array from './array.js';
import * as code from './code.js';
import * as collection from './collection.js';
import * as comparison from './comparison.js';
import * as html from './html.js';
import * as i18n from './i18n.js';
import * as inflection from './inflection.js';
import * as match from './match.js';
import * as math from './math.js';
import * as misc from './misc.js';
import * as number from './number.js';
import * as object from './object.js';
import * as path from './path.js';
import * as regex from './regex.js';
import * as string from './string.js';
import * as url from './url.js';
import * as uuid from './uuid.js';

export default {
array,
code,
collection,
comparison,
html,
i18n,
inflection,
match,
math,
misc,
number,
object,
path,
regex,
string,
url,
uuid
};
39 changes: 0 additions & 39 deletions lib/index.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion lib/inflection.mjs → lib/inflection.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import { indexOf } from './utils/index.mjs';
import { indexOf } from './utils/index.js';

/**
* Returns either the `singular` or `plural` inflection of a word based on
Expand Down
2 changes: 1 addition & 1 deletion lib/match.mjs → lib/match.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import * as utils from './utils/index.mjs';
import * as utils from './utils/index.js';

import micromatch from 'micromatch';

Expand Down
2 changes: 1 addition & 1 deletion lib/math.mjs → lib/math.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import * as utils from './utils/index.mjs';
import * as utils from './utils/index.js';

/**
* Return the magnitude of `a`.
Expand Down
4 changes: 2 additions & 2 deletions lib/misc.mjs → lib/misc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

import {options as _options} from './utils/index.mjs';
import {options as _options} from './utils/index.js';

import getValue from 'get-value';
import createFrame from './utils/createFrame.mjs';
import createFrame from './utils/createFrame.js';

/**
* Block helper for exposing private `@` variables on the context
Expand Down
2 changes: 1 addition & 1 deletion lib/number.mjs → lib/number.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import * as util from './utils/index.mjs';
import * as util from './utils/index.js';

/**
* Format a number to it's equivalent in bytes. If a string is passed,
Expand Down
8 changes: 4 additions & 4 deletions lib/object.mjs → lib/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

var hasOwn = Object.hasOwnProperty;

import isOptions from './utils/isOptions.mjs';
import isObject from './utils/isObject.mjs';
import isOptions from './utils/isOptions.js';
import isObject from './utils/isObject.js';
var util = {
isOptions,
isObject
};
import { arrayify } from './array.mjs';
import { arrayify } from './array.js';

import getValue from 'get-value';
import getObject from 'get-object';
import createFrame from './utils/createFrame.mjs';
import createFrame from './utils/createFrame.js';

/**
* Extend the context with the properties of other objects.
Expand Down
2 changes: 1 addition & 1 deletion lib/path.mjs → lib/path.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import * as util from './utils/index.mjs';
import * as util from './utils/index.js';
import path from 'path';
import _relative from 'relative';

Expand Down
2 changes: 1 addition & 1 deletion lib/regex.mjs → lib/regex.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import * as util from './utils/index.mjs';
import * as util from './utils/index.js';

import kindOf from 'kind-of';

Expand Down
6 changes: 3 additions & 3 deletions lib/string.mjs → lib/string.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import * as utils from './utils/index.mjs';
import loremText from './utils/lorem.mjs';
import * as utils from './utils/index.js';
import loremText from './utils/lorem.js';

/**
* Append the specified `suffix` to the given string.
Expand Down Expand Up @@ -512,7 +512,7 @@ export const replaceFirst = function(str, a, b) {
* @example {{reverse 'abcde'}} -> edcba
*/

export { reverse} from './array.mjs';
export { reverse} from './array.js';

/**
* Sentence case the given string
Expand Down
2 changes: 1 addition & 1 deletion lib/url.mjs → lib/url.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import { resolve, parse } from 'url';
import * as util from './utils/index.mjs';
import * as util from './utils/index.js';
import * as qs from 'querystring';

/**
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/utils/fn.mjs → lib/utils/fn.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import isBlock from './isBlock.mjs';
import isOptions from './isOptions.mjs';
import isBlock from './isBlock.js';
import isOptions from './isOptions.js';

/**
* This code was taken directly from handlebars-helpers,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/html.mjs → lib/utils/html.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import { isString } from './index.mjs';
import { isString } from './index.js';
import striptags from 'striptags';

/**
Expand Down
File renamed without changes.
20 changes: 10 additions & 10 deletions lib/utils/index.mjs → lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ export const arrayify = function(val) {
return val != null ? (Array.isArray(val) ? val : [val]) : [];
};

import _isOptions from './isOptions.mjs';
import _value from './value.mjs';
import _isString from './isString.mjs';
import _fn from './fn.mjs';
import _isObject from './isObject.mjs';
import _inverse from './inverse.mjs';
import _isUndefined from './isUndefined.mjs';
import _options from './options.mjs';
import _result from './result.mjs';
import _indexOf from './indexOf.mjs';
import _isOptions from './isOptions.js';
import _value from './value.js';
import _isString from './isString.js';
import _fn from './fn.js';
import _isObject from './isObject.js';
import _inverse from './inverse.js';
import _isUndefined from './isUndefined.js';
import _options from './options.js';
import _result from './result.js';
import _indexOf from './indexOf.js';

export const isOptions = _isOptions;
export const value = _value;
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions lib/utils/inverse.mjs → lib/utils/inverse.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

import identity from './identity.mjs';
import isBlock from './isBlock.mjs';
import isOptions from './isOptions.mjs';
import identity from './identity.js';
import isBlock from './isBlock.js';
import isOptions from './isOptions.js';

/**
* This code was taken directly from handlebars-helpers,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/isBlock.mjs → lib/utils/isBlock.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import isOptions from './isOptions.mjs';
import isOptions from './isOptions.js';

/**
* This code was taken directly from handlebars-helpers,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/utils/isOptions.mjs → lib/utils/isOptions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import isObject from './isObject.mjs';
import isObject from './isObject.js';

/**
* This code was taken directly from handlebars-helpers,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/utils/isUndefined.mjs → lib/utils/isUndefined.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import isOptions from './isOptions.mjs';
import isOptions from './isOptions.js';

/**
* This code was taken directly from handlebars-helpers,
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/utils/options.mjs → lib/utils/options.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import isObject from './isObject.mjs';
import isOptions from './isOptions.mjs';
import isObject from './isObject.js';
import isOptions from './isOptions.js';

/**
* This code was taken directly from handlebars-helpers,
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/utils/value.mjs → lib/utils/value.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import isBlock from './isBlock.mjs';
import isOptions from './isOptions.mjs';
import isBlock from './isBlock.js';
import isOptions from './isOptions.js';

/**
* This code was taken directly from handlebars-helpers,
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "@budibase/handlebars-helpers",
"type": "module",
"description": "More than 130 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate, Verb, Ghost, gulp-handlebars, grunt-handlebars, consolidate, or any node.js/Handlebars project.",
"version": "0.14.0",
"homepage": "https://github.com/Budibase/handlebars-helpers",
Expand Down Expand Up @@ -64,12 +65,12 @@
"index.js",
"lib"
],
"main": "index.mjs",
"main": "index.js",
"engines": {
"node": ">=10.12.0"
},
"scripts": {
"lint": "eslint --ext js,mjs .",
"lint": "eslint --ext js .",
"test": "mocha",
"update:readmemd": "verb"
},
Expand Down
Loading