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

Version 4.4.3 #175

Merged
merged 7 commits into from
Oct 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Updated Build Script to convert common js to module js
Ansul Agrawal committed Oct 28, 2024
commit 486f29f9f4eb7551088499a191b03e4f5da4c22a
5 changes: 4 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
"presets": [
["@babel/preset-env", { "modules": false }],
"@babel/preset-react"
]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
},
49 changes: 0 additions & 49 deletions scripts/build.cjs

This file was deleted.

53 changes: 53 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -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(',')}"`);

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.
This shell command depends on an uncontrolled
absolute path
.
This shell command depends on an uncontrolled
absolute path
.
This shell command depends on an uncontrolled
absolute path
.

// 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();