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

Remove node-emoji dependency #902

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eight-shoes-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sku': patch
---

Remove `node-emoji` dependency
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ const didYouMean = require('didyoumean2').default;
const validator = new Validator();

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The perf gains are going to be 🤯


console.log(bold(underline(red('SkuWebpackPlugin: Invalid options'))));
errors.forEach((error) => {
console.log(yellow(emojify(error)));
console.log(yellow(error));
});
process.exit(1);
};
Expand Down Expand Up @@ -85,16 +83,16 @@ module.exports = (options) => {
const suggestedMessage = suggestedKey
? ` Did you mean '${bold(suggestedKey)}'?`
: '';
errors.push(`:question: ${unknownMessage}${suggestedMessage}`);
errors.push(` ${unknownMessage}${suggestedMessage}`);
});

// Validate schema types
const schemaCheckResult = validate(options);
if (schemaCheckResult !== true) {
schemaCheckResult.forEach(({ message, field }) => {
const errorMessage = message
? `:no_entry_sign: ${message.replace(field, `${bold(field)}`)}`
: `:no_entry_sign: '${bold(field)}' is invalid`;
? `🚫 ${message.replace(field, `${bold(field)}`)}`
: `🚫 '${bold(field)}' is invalid`;

errors.push(errorMessage);
});
Expand All @@ -106,7 +104,7 @@ module.exports = (options) => {
browserslist(options.browserslist);
} catch (e) {
errors.push(
`:no_entry_sign: '${bold(
`🚫 '${bold(
'browserslist',
)}' must be a valid browserslist query. ${white(e.message)}`,
);
Expand Down
18 changes: 7 additions & 11 deletions packages/sku/context/validateConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ const defaultClientEntry = require('./defaultClientEntry');
const availableConfigKeys = Object.keys(defaultSkuConfig);

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)));
console.log(yellow(error));
});
process.exit(1);
};
Expand All @@ -30,16 +28,16 @@ module.exports = (skuConfig) => {
const suggestedMessage = suggestedKey
? ` Did you mean '${bold(suggestedKey)}'?`
: '';
errors.push(`:question: ${unknownMessage}${suggestedMessage}`);
errors.push(` ${unknownMessage}${suggestedMessage}`);
});

// Validate schema types
const schemaCheckResult = configSchema(skuConfig);
if (schemaCheckResult !== true) {
schemaCheckResult.forEach(({ message, field }) => {
const errorMessage = message
? `:no_entry_sign: ${message.replace(field, `${bold(field)}`)}`
: `:no_entry_sign: '${bold(field)}' is invalid`;
? `🚫 ${message.replace(field, `${bold(field)}`)}`
: `🚫 '${bold(field)}' is invalid`;

errors.push(errorMessage);
});
Expand All @@ -48,9 +46,7 @@ module.exports = (skuConfig) => {
// Validate library entry has corresponding libraryName
if (skuConfig.libraryEntry && !skuConfig.libraryName) {
errors.push(
`:no_entry_sign: '${bold(
'libraryEntry',
)}' must have a corresponding '${bold(
`🚫 '${bold('libraryEntry')}' must have a corresponding '${bold(
'libraryName',
)}' option. More details: ${underline(
'https://github.com/seek-oss/sku#building-a-library',
Expand All @@ -62,7 +58,7 @@ module.exports = (skuConfig) => {
skuConfig.routes.forEach(({ name }) => {
if (name === defaultClientEntry) {
errors.push(
`:no_entry_sign: Invalid route name: '${bold(
`🚫 Invalid route name: '${bold(
defaultClientEntry,
)}', please use a different route name`,
);
Expand All @@ -74,7 +70,7 @@ module.exports = (skuConfig) => {
browserslist(skuConfig.supportedBrowsers);
} catch (e) {
errors.push(
`:no_entry_sign: '${bold(
`🚫 '${bold(
'supportedBrowsers',
)}' must be a valid browserslist query. ${white(e.message)}`,
);
Expand Down
1 change: 0 additions & 1 deletion packages/sku/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
"lint-staged": "^11.1.1",
"memoizee": "^0.4.15",
"mini-css-extract-plugin": "^2.6.1",
"node-emoji": "^2.1.0",
"node-html-parser": "^6.1.1",
"open": "^7.3.1",
"path-to-regexp": "^6.2.0",
Expand Down
33 changes: 0 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.