Skip to content

Commit

Permalink
Remove rimraf dependency in favour of Node.Js's rm method
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed May 7, 2024
1 parent 111c591 commit c5e07c5
Show file tree
Hide file tree
Showing 13 changed files with 206 additions and 207 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-rockets-invent.md
@@ -0,0 +1,5 @@
---
'sku': patch
---

Remove `rimraf` dependency in favour of Node.JS's `rm` method
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -63,7 +63,6 @@
"prettier": "^2.8.8",
"puppeteer": "^21.6.0",
"renovate-config-seek": "^0.4.0",
"rimraf": "^5.0.0",
"typescript": "*"
},
"volta": {
Expand Down
3 changes: 3 additions & 0 deletions packages/sku/config/webpack/outputs.js
@@ -0,0 +1,3 @@
const staticRenderEntryFilename = 'render.js';

module.exports = { staticRenderEntryFilename };
3 changes: 2 additions & 1 deletion packages/sku/config/webpack/webpack.config.js
Expand Up @@ -25,6 +25,7 @@ const statsConfig = require('./statsConfig');
const getSourceMapSetting = require('./sourceMaps');
const getCacheSettings = require('./cache');
const modules = require('./resolveModules');
const { staticRenderEntryFilename } = require('./outputs.js');

const {
paths,
Expand Down Expand Up @@ -274,7 +275,7 @@ const makeWebpackConfig = ({
output: {
path: paths.target,
publicPath: paths.publicPath,
filename: 'render.js',
filename: staticRenderEntryFilename,
libraryExport: 'default',
library: 'static',
libraryTarget: 'umd2',
Expand Down
14 changes: 8 additions & 6 deletions packages/sku/lib/buildFileUtils.js
@@ -1,13 +1,15 @@
// @ts-check
const path = require('node:path');
const fs = require('node:fs/promises');
const { rimraf } = require('rimraf');

const { staticRenderEntryFilename } = require('../config/webpack/outputs');

const { paths } = require('../context');
const exists = require('./exists');
const copyDirContents = require('./copyDirContents');

const cleanTargetDirectory = () => rimraf(`${paths.target}/*`, { glob: true });
const cleanTargetDirectory = () =>
fs.rm(`${paths.target}/*`, { recursive: true, force: true });

const copyPublicFiles = async () => {
if (await exists(paths.public)) {
Expand All @@ -19,14 +21,14 @@ const ensureTargetDirectory = async () => {
await fs.mkdir(paths.target, { recursive: true });
};

const cleanRenderJs = async () => {
const renderFileGlob = path.join(paths.target, '*render.js');
await rimraf(renderFileGlob, { glob: true });
const cleanStaticRenderEntry = async () => {
const renderFile = path.join(paths.target, staticRenderEntryFilename);
await fs.rm(renderFile);
};

module.exports = {
cleanTargetDirectory,
copyPublicFiles,
ensureTargetDirectory,
cleanRenderJs,
cleanStaticRenderEntry,
};
1 change: 0 additions & 1 deletion packages/sku/package.json
Expand Up @@ -110,7 +110,6 @@
"prettier": "^2.8.8",
"pretty-ms": "^7.0.1",
"react-refresh": "^0.14.0",
"rimraf": "^5.0.0",
"selfsigned": "^2.1.1",
"semver": "^7.3.4",
"serialize-javascript": "^6.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/sku/scripts/build-storybook.js
@@ -1,7 +1,7 @@
// First, ensure the build is running in production mode
process.env.NODE_ENV = 'production';

const { rimraf } = require('rimraf');
const { rm } = require('node:fs/promises');
const { argv, config } = require('../config/args');
const gracefulSpawn = require('../lib/gracefulSpawn');
const { storybookTarget } = require('../context');
Expand All @@ -11,7 +11,7 @@ const { setUpStorybookConfigDirectory } = require('../lib/storybook');

(async () => {
await runVocabCompile();
await rimraf(storybookTarget);
await rm(storybookTarget, { recursive: true, force: true });
await setUpStorybookConfigDirectory();

argv.push('build');
Expand Down
4 changes: 2 additions & 2 deletions packages/sku/scripts/build.js
Expand Up @@ -10,7 +10,7 @@ const {
copyPublicFiles,
cleanTargetDirectory,
ensureTargetDirectory,
cleanRenderJs,
cleanStaticRenderEntry,
} = require('../lib/buildFileUtils');
const { run } = require('../lib/runWebpack');
const createHtmlRenderPlugin = require('../config/webpack/plugins/createHtmlRenderPlugin');
Expand All @@ -31,7 +31,7 @@ const { runVocabCompile } = require('../lib/runVocab');
}),
),
);
await cleanRenderJs();
await cleanStaticRenderEntry();
await copyPublicFiles();

const timeTaken = performance.now();
Expand Down

0 comments on commit c5e07c5

Please sign in to comment.