Skip to content

Commit

Permalink
fix: update all dependencies to the latest versions (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
magicmatatjahu authored Nov 24, 2022
1 parent f0f646d commit f7b2daf
Show file tree
Hide file tree
Showing 24 changed files with 47,561 additions and 24,967 deletions.
111 changes: 84 additions & 27 deletions craco.config.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,86 @@
// eslint-disable-next-line
const crypto = require('crypto'); // Force method use SHA-256 to address
const cryptCreateHashOrig = crypto.createHash; // OpenSSL 3.0 deprecation of
crypto.createHash = () => cryptCreateHashOrig('sha256'); // MD4 algorithm

module.exports = {
style: {
postcss: {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
],
},
},
webpack: {
configure: (webpackConfig) => {
webpackConfig.module.rules.push({
test: /\.yml$/i,
loader: 'raw-loader',
});

webpackConfig.resolve.alias = webpackConfig.resolve.alias || {};
webpackConfig.resolve.alias['nimma/fallbacks'] = require.resolve('./node_modules/nimma/dist/legacy/cjs/fallbacks/index.js');
webpackConfig.resolve.alias['nimma/legacy'] = require.resolve('./node_modules/nimma/dist/legacy/cjs/index.js');

return webpackConfig;
/* eslint-disable */

const crypto = require('crypto');
const webpack = require('webpack');

function getFileLoaderRule(rules) {
for (const rule of rules) {
if ("oneOf" in rule) {
const found = getFileLoaderRule(rule.oneOf);
if (found) {
return found;
}
} else if (rule.test === undefined && rule.type === 'asset/resource') {
return rule;
}
}
};
throw new Error("File loader not found");
}

function configureWebpack(webpackConfig) {
// fallbacks
const fallback = webpackConfig.resolve.fallback || {};
Object.assign(fallback, {
assert: require.resolve('assert/'),
buffer: require.resolve('buffer'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
path: require.resolve('path-browserify'),
stream: require.resolve('stream-browserify'),
zlib: require.resolve('browserify-zlib'),
url: require.resolve('url/'),
util: require.resolve('util/'),
fs: false,
});
webpackConfig.resolve.fallback = fallback;

// aliases
webpackConfig.resolve.alias = webpackConfig.resolve.alias || {};
webpackConfig.resolve.alias['nimma/fallbacks'] = require.resolve('./node_modules/nimma/dist/legacy/cjs/fallbacks/index.js');
webpackConfig.resolve.alias['nimma/legacy'] = require.resolve('./node_modules/nimma/dist/legacy/cjs/index.js');

// plugins
webpackConfig.plugins = (webpackConfig.plugins || []).concat([
new webpack.ProvidePlugin({
process: 'process/browser.js',
Buffer: ['buffer', 'Buffer']
})
]);

// rules/loaders
// workaround for https://github.com/facebook/create-react-app/issues/11889 issue
const fileLoaderRule = getFileLoaderRule(webpackConfig.module.rules);
fileLoaderRule.exclude.push(/\.cjs$/);
webpackConfig.module.rules.push({
test: /\.yml$/i,
type: 'asset/source',
});

// ignore source-map warnings
webpackConfig.ignoreWarnings = [...(webpackConfig.ignoreWarnings || []), /Failed to parse source map/];

return webpackConfig;
}

// Force method use SHA-256 to address OpenSSL 3.0 deprecation of MD4 algorithm
function configureCrypto() {
const cryptCreateHashOrig = crypto.createHash;
crypto.createHash = () => cryptCreateHashOrig('sha256');
}

function setEnvironments() {
process.env.DISABLE_ESLINT_PLUGIN = true;
}

function configureCraco() {
setEnvironments();
configureCrypto();

return {
webpack: {
configure: configureWebpack,
}
};
}

module.exports = configureCraco();
Loading

0 comments on commit f7b2daf

Please sign in to comment.