-
-
Notifications
You must be signed in to change notification settings - Fork 345
feat: implement rslib with TypeScript declaration generation #3883
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
base: main
Are you sure you want to change the base?
Conversation
- Configure rslib to generate TypeScript declaration files (.d.ts) - Add missing entry points (helpers, core, global) to rslib config - Update runtime-core package.json exports to use generated declarations - Fix import patterns in runtime package to use namespace imports - Exclude dist directories from TypeScript compilation to prevent conflicts - Add global variable definitions for build-time replacement - Update multiple package tsconfigs to prevent dual type resolution This enables proper TypeScript declaration generation via rslib while maintaining compatibility with existing build processes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
❌ Deploy Preview for module-federation-docs failed. Why did it fail? →
|
const args = ['rslib', 'build']; | ||
|
||
if (options.configFile && options.configFile !== 'rslib.config.ts') { | ||
args.push('--config', options.configFile); |
Check warning
Code scanning / CodeQL
Unsafe shell command constructed from library input Medium
library input
shell command
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 days ago
To fix the issue, we should avoid constructing the shell command as a single string and instead use a safer API like execFile
, which accepts the command and its arguments as separate parameters. This approach prevents the shell from interpreting special characters in the input. Specifically:
- Replace the use of
exec
withexecFile
. - Pass the
args
array directly toexecFile
as the command arguments. - Ensure that the
options.configFile
value is properly validated or sanitized before being added to theargs
array.
-
Copy modified line R2 -
Copy modified line R48 -
Copy modified line R51
@@ -1,3 +1,3 @@ | ||
import type { ExecutorContext } from '@nx/devkit'; | ||
import { exec } from 'child_process'; | ||
import { execFile } from 'child_process'; | ||
import { promisify } from 'util'; | ||
@@ -46,9 +46,7 @@ | ||
|
||
const command = args.join(' '); | ||
|
||
try { | ||
console.info(`Running: ${command}`); | ||
console.info(`Running: ${args.join(' ')}`); | ||
console.info(`Working directory: ${join(context.root, projectRoot)}`); | ||
|
||
const { stdout, stderr } = await promisify(exec)(command, { | ||
const { stdout, stderr } = await promisify(execFile)(args[0], args.slice(1), { | ||
cwd: join(context.root, projectRoot), |
The tools/scripts/publish.mjs file was not referenced anywhere in the codebase and appears to be legacy/template code that was never integrated into the actual publishing workflow. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Replace @nx/rollup executor with rslib for runtime-core package - Add @rslib/core as devDependency and create rslib.config.ts - Update package.json exports to match rslib output format (.js/.cjs) - Add TypeScript declaration generation with proper env.d.ts - Update tsconfig.lib.json for correct output paths - Remove duplicate global.d.ts file - Add build script to package.json for direct rslib execution This migration enables better TypeScript declaration generation and aligns with modern build tooling standards. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Move global declarations from src/global.ts to separate global-types.d.ts - This prevents conflicts between source and generated .d.ts files - Resolves TypeScript errors where packages saw both src and dist types - Enhanced package now builds successfully without type conflicts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Configure project.json to use ../../tools/rslib-plugin:build executor - Fix rslib.config.ts import to use JSON import instead of fs.readFileSync - Add @rslib/core devDependency to package.json - Ensure proper rslib configuration for TypeScript declaration generation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary
Key Changes
.d.ts
generation via rslibpnpm build
andnx run runtime-core:build
work correctlyTest plan
🤖 Generated with Claude Code