Skip to content

Commit

Permalink
perf: update default export to be ES6
Browse files Browse the repository at this point in the history
This commit updates a few things to hopefully more ES6 compatible.

Updates include creating a new ES6 compatible export in the dist
directory while also retaining the ES5 versions for the tests.

Changes to be committed:
modified:   scripts/generate.js
modified:   tests/index.test.js
  • Loading branch information
blackfalcon committed Feb 10, 2024
1 parent 524b0f2 commit 0c86410
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions scripts/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
const dataFile = '../src/data/icons.json';
const restrictedDataFile = '../src/data/restrictedIcons.json';
const logoDataFile = '../src/data/logoIcons.json';
const indexFile = `${__dirname}/../dist/index.js`;
const indexFileES5 = `${__dirname}/../dist/index_es5.js`;
const indexFileES6 = `${__dirname}/../dist/index.js`;
const iconsDir = `${__dirname}/../src`;
const iconData = require(dataFile);
const restrictedIconData = require(restrictedDataFile);
Expand Down Expand Up @@ -171,4 +172,5 @@ Generating the Icons People Love.
`))

// write our generic index.js
fs.writeFileSync(indexFile, `module.exports=${JSON.stringify(icons)};`);
fs.writeFileSync(indexFileES5, `module.exports=${JSON.stringify(icons)};`);
fs.writeFileSync(indexFileES6, `export default ${JSON.stringify(icons)};`);
4 changes: 2 additions & 2 deletions tests/index.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { icons } = require('../src/data/icons.json');
const orionIcons = require('../dist/index.js');
const auroIcons = require('../dist/index_es5.js');

icons.forEach(icon => {
const subject = orionIcons[icon.name];
const subject = auroIcons[icon.name];

test(`${icon.name} has a "title"`, () => {
expect(typeof subject.title).toBe('string');
Expand Down

0 comments on commit 0c86410

Please sign in to comment.