From 486f29f9f4eb7551088499a191b03e4f5da4c22a Mon Sep 17 00:00:00 2001 From: Ansul Agrawal Date: Mon, 28 Oct 2024 16:45:39 +0530 Subject: [PATCH 1/5] Updated Build Script to convert common js to module js --- .babelrc | 5 ++++- package.json | 2 +- scripts/build.cjs | 49 ------------------------------------------- scripts/build.js | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 51 deletions(-) delete mode 100644 scripts/build.cjs create mode 100644 scripts/build.js diff --git a/.babelrc b/.babelrc index 2b7bafa..dc50a7f 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,6 @@ { - "presets": ["@babel/preset-env", "@babel/preset-react"] + "presets": [ + ["@babel/preset-env", { "modules": false }], + "@babel/preset-react" + ] } diff --git a/package.json b/package.json index 67b10ae..080f9fe 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "scripts": { "start": "vite", "build": "vite build", - "build-lib": "node scripts/build.cjs", + "build-lib": "node scripts/build.js", "clean": "rimraf ./dist && mkdir dist", "lint": "eslint ./src" }, diff --git a/scripts/build.cjs b/scripts/build.cjs deleted file mode 100644 index caa2ad1..0000000 --- a/scripts/build.cjs +++ /dev/null @@ -1,49 +0,0 @@ -// Do this as the first thing so that any code reading it knows the right env. -process.env.BABEL_ENV = 'production'; -process.env.NODE_ENV = 'production'; - -// Makes the script crash on unhandled rejections instead of silently -// ignoring them. In the future, promise rejections that are not handled will -// terminate the Node.js process with a non-zero exit code. -process.on('unhandledRejection', err => { - throw err; -}); - -const util = require('util'); -const path = require('path'); -const exec = util.promisify(require('child_process').exec); -// eslint-disable-next-line import/no-extraneous-dependencies -const fs = require('fs-extra'); - -async function build() { - const root = path.resolve(__dirname, '..'); - const sourceDir = path.resolve(root, 'src'); - const targetDir = path.resolve(root, 'dist'); - const typingDir = path.resolve(root, 'typing'); - const jsTarget = targetDir; - const cssTarget = path.resolve(targetDir, 'css'); - const excludedFolders = ['examples', 'main.jsx']; - - try { - // clean - process.stdout.write('Cleaning... \n'); - await exec('npm run clean'); - - // transpiling and copy js - process.stdout.write('Transpiling js with babel... \n'); - await exec(`babel ${sourceDir} --out-dir ${jsTarget} --ignore "${excludedFolders.map(folder => path.join(sourceDir, folder)).join(',')}"`); - - process.stdout.write('Copying CSS Files... \n'); - await fs.copy(`${sourceDir}/css/`, cssTarget); - - process.stdout.write('Copying Typescript Files... \n'); - await fs.copy(`${typingDir}/`, targetDir); - - process.stdout.write('Success! \n'); - } catch (e) { - console.log(e); - process.exit(); - } -} - -build(); diff --git a/scripts/build.js b/scripts/build.js new file mode 100644 index 0000000..2debe55 --- /dev/null +++ b/scripts/build.js @@ -0,0 +1,53 @@ +// Do this as the first thing so that any code reading it knows the right env. +process.env.BABEL_ENV = 'production'; +process.env.NODE_ENV = 'production'; + +import path from 'path'; +import { fileURLToPath } from 'url'; +import { exec } from 'child_process'; +import fs from 'fs-extra'; +import { promisify } from 'util'; + +const execPromise = promisify(exec); +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +async function build() { + const root = path.resolve(__dirname, '..'); + const sourceDir = path.resolve(root, 'src'); + const targetDir = path.resolve(root, 'dist'); + const typingDir = path.resolve(root, 'typing'); + const jsTarget = targetDir; + const cssTarget = path.resolve(targetDir, 'css'); + const excludedFolders = ['examples', 'main.jsx']; + + try { + // Validate source and target directories + await fs.ensureDir(sourceDir); + await fs.ensureDir(targetDir); + + // Clean previous build + console.log('Cleaning...'); + await execPromise('npm run clean'); + + // Transpile JS files using Babel, excluding specific folders + console.log('Transpiling JavaScript files with Babel... \n'); + await execPromise(`babel ${sourceDir} --out-dir ${jsTarget} --ignore "${excludedFolders.map(folder => path.join(sourceDir, folder)).join(',')}"`); + + // Copy CSS files + console.log('Copying CSS Files...'); + await fs.copy(`${sourceDir}/css/`, cssTarget); + + // Copy TypeScript declaration files + console.log('Copying TypeScript Files...'); + await fs.copy(`${typingDir}/`, targetDir); + + console.log('Build process completed successfully!'); + } catch (e) { + console.error('Build process failed:', e.message); + console.error('Stack trace:', e.stack); + process.exit(1); + } +} + +build(); From 6f211118b5df94f14b10717a7fa00024ef6758bf Mon Sep 17 00:00:00 2001 From: Ansul Agrawal Date: Mon, 28 Oct 2024 16:47:42 +0530 Subject: [PATCH 2/5] 4.4.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 080f9fe..bc7aac5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-big-schedule", - "version": "4.4.2", + "version": "4.4.3", "description": "React Big Schedule is a powerful and intuitive scheduler and resource planning solution built with React. Seamlessly integrate this modern browser-compatible component into your applications to effectively manage time, appointments, and resources. With drag-and-drop functionality, interactive UI, and granular views, react-big-schedule empowers users to effortlessly schedule and allocate resources with precision. Enhance productivity and streamline your workflow with this React-based solution, designed to optimize time management and simplify calendar-based operations. Perfect for applications requiring advanced scheduling capabilities, react-big-schedule offers a seamless and intuitive experience for managing appointments, resource allocation, and time slots. Unlock the potential of your React projects with react-big-schedule and revolutionize the way you handle scheduling and resource planning. It is the updated version of react-big-scheduler", "keywords": [ "react-big-schedule", From baf04756982c6658f626f44cdac21d9d3ad2c288 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Mon, 28 Oct 2024 11:19:02 +0000 Subject: [PATCH 3/5] [CodeFactor] Apply fixes to commit 486f29f [ci skip] [skip ci] --- scripts/build.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index 2debe55..9b89913 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -1,13 +1,13 @@ // Do this as the first thing so that any code reading it knows the right env. -process.env.BABEL_ENV = 'production'; -process.env.NODE_ENV = 'production'; - import path from 'path'; import { fileURLToPath } from 'url'; import { exec } from 'child_process'; import fs from 'fs-extra'; import { promisify } from 'util'; +process.env.BABEL_ENV = 'production'; +process.env.NODE_ENV = 'production'; + const execPromise = promisify(exec); const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -25,7 +25,7 @@ async function build() { // Validate source and target directories await fs.ensureDir(sourceDir); await fs.ensureDir(targetDir); - + // Clean previous build console.log('Cleaning...'); await execPromise('npm run clean'); From 288c4f8eec12b8added045abc83ff45eaff4bd69 Mon Sep 17 00:00:00 2001 From: Ansul Agrawal Date: Mon, 28 Oct 2024 16:50:40 +0530 Subject: [PATCH 4/5] Updated changelog file --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76b2067..6f86d6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Logs: +## [4.4.3](https://github.com/react-scheduler/react-big-schedule/compare/4.4.2...4.4.3) +`2024-10-28` + +- Change the build type from `common.js` to `module.js` by [@ansulagrawal](https://github.com/ansulagrawal) in [#174](https://github.com/react-scheduler/react-big-schedule/pull/175). + ## [4.4.2](https://github.com/react-scheduler/react-big-schedule/compare/4.4.1...4.4.2) `2024-10-25` From 7ca22b475d36a4c7cb14d180ff594a0f126b490e Mon Sep 17 00:00:00 2001 From: Ansul Agrawal Date: Mon, 28 Oct 2024 16:55:37 +0530 Subject: [PATCH 5/5] Fix --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f86d6e..cdcd7de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## [4.4.3](https://github.com/react-scheduler/react-big-schedule/compare/4.4.2...4.4.3) `2024-10-28` -- Change the build type from `common.js` to `module.js` by [@ansulagrawal](https://github.com/ansulagrawal) in [#174](https://github.com/react-scheduler/react-big-schedule/pull/175). +- Change the build type from `common.js` to `module.js` by [@ansulagrawal](https://github.com/ansulagrawal) in [#174](https://github.com/react-scheduler/react-big-schedule/pull/174). ## [4.4.2](https://github.com/react-scheduler/react-big-schedule/compare/4.4.1...4.4.2) `2024-10-25`