Skip to content

Commit

Permalink
Async import node-emoji (#900)
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed Nov 20, 2023
1 parent aa48154 commit 2b930a0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/stupid-news-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sku': patch
---

Asynchronously import `node-emoji` to fix ESM require issue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ const Validator = require('fastest-validator');
const browserslist = require('browserslist');
const { yellow, red, bold, underline, white } = require('chalk');
const didYouMean = require('didyoumean2').default;
const { emojify } = require('node-emoji');

const validator = new Validator();

const exitWithErrors = (errors) => {
const exitWithErrors = async (errors) => {
const { emojify } = await import('node-emoji');

console.log(bold(underline(red('SkuWebpackPlugin: Invalid options'))));
errors.forEach((error) => {
console.log(yellow(emojify(error)));
Expand Down
5 changes: 3 additions & 2 deletions packages/sku/context/validateConfig.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const browserslist = require('browserslist');
const { yellow, red, bold, underline, white } = require('chalk');
const didYouMean = require('didyoumean2').default;
const { emojify } = require('node-emoji');

const configSchema = require('./configSchema');
const defaultSkuConfig = require('./defaultSkuConfig');
const defaultClientEntry = require('./defaultClientEntry');

const availableConfigKeys = Object.keys(defaultSkuConfig);

const exitWithErrors = (errors) => {
const exitWithErrors = async (errors) => {
const { emojify } = await import('node-emoji');

console.log(bold(underline(red('Errors in sku config:'))));
errors.forEach((error) => {
console.log(yellow(emojify(error)));
Expand Down

0 comments on commit 2b930a0

Please sign in to comment.