-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: support more special fields of target runtime #22
Conversation
Warning Rate limit exceeded@prisis has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 28 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe changes involve updates to various Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Thank you for following the naming conventions! 🙏 |
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@rollup/plugin-node-resolve@15.2.4, npm/@swc/core@1.7.26, npm/@types/react@18.3.8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Outside diff range and nitpick comments (13)
packages/packem/__fixtures__/module-conditions/import-module-require/require.cjs (1)
1-1
: LGTM! Consider adding a brief explanatory comment.The implementation is correct and serves its purpose as a test fixture for CommonJS module resolution. The exported value clearly indicates that this module is intended to be resolved using the
require
syntax.Consider adding a brief comment at the top of the file to explain its purpose:
+// Test fixture for CommonJS module resolution exports.resolved = "require";
This addition would improve maintainability by making the file's purpose immediately clear to other developers.
packages/packem/__fixtures__/module-conditions/module-and-require/require.cjs (1)
1-1
: LGTM! Consider adding a brief comment.The implementation is correct and straightforward, using proper CommonJS syntax to export a single property. This fixture file seems well-suited for its purpose in testing module resolution or conditional exports.
Consider adding a brief comment at the top of the file to explain its purpose within the test suite. This can help other developers quickly understand the role of this fixture. For example:
+// Fixture file for testing CommonJS module resolution exports.resolved = "require";
packages/packem/__fixtures__/module-conditions/import-module-require/module.js (1)
1-1
: LGTM! Consider adding a brief comment for context.The code is correct and follows modern JavaScript practices. The constant is exported properly, making it available for use in other modules.
Consider adding a brief comment to explain the purpose of this constant in the context of the test fixture. This can help other developers understand its role more quickly. For example:
// Constant used to verify correct module resolution in import condition tests export const resolved = "module";packages/packem/__fixtures__/module-conditions/module-import-require/import.js (1)
1-1
: LGTM! Consider adding a brief comment for context.The code is correct and serves its purpose as a test fixture. The constant name and value are clear and aligned with the file name.
Consider adding a brief comment to provide context for future developers:
+// Test fixture for ES module import resolution export const resolved = "import";
This addition would make the purpose of the file immediately clear to anyone reviewing the test suite.
packages/packem/__fixtures__/module-conditions/module-require-import/module.js (1)
1-1
: LGTM! Consider adding a brief comment.The code is clean, concise, and follows modern JavaScript practices. It exports a constant
resolved
with the value "module", which aligns well with the file's purpose in the test fixture.Consider adding a brief comment to explain the purpose of this constant in the context of the test fixture. This can help other developers understand its role more quickly. For example:
+// Constant used to verify correct module resolution in test scenarios export const resolved = "module";
packages/packem/__fixtures__/module-conditions/module-require-import/require.cjs (1)
1-1
: LGTM! Consider adding a brief comment for clarity.The code is correct and serves its purpose as a test fixture for module conditions. The
export
statement is valid in a.cjs
file, which denotes a CommonJS module.Note: The static analysis tool (Biome) reports an error about illegal use of export declaration. This is a false positive, as
.cjs
files are explicitly CommonJS modules whereexport
statements are valid for ES module interoperability.For improved clarity, consider adding a brief comment explaining the purpose of this constant:
+// Constant to identify CommonJS require resolution export const resolved = "require";
🧰 Tools
Biome
[error] 1-1: Illegal use of an export declaration outside of a module
not allowed inside scripts
(parse)
packages/packem/__fixtures__/module-conditions/module-and-import/package.json (2)
4-7
: Consider clarifying the "module-sync" condition name.The Node.js specific exports are well-structured, providing different entry points for different module systems. However, the "module-sync" condition name is non-standard and might be confusing.
Consider renaming "module-sync" to a more standard condition name, such as "require" or "commonjs", if it's intended for CommonJS usage. If it's for ESM, consider using "module" instead. This would improve clarity and align with common practices.
1-10
: Well-structured package.json for testing conditional exports.This
package.json
file is well-crafted to serve as a test fixture for conditional exports. It correctly demonstrates various module resolution scenarios, which is valuable for testing purposes. The structure follows Node.js best practices for conditional exports, ensuring compatibility with different module systems.As this file is likely part of a test suite, consider adding more edge cases or complex conditional export scenarios in future iterations to enhance test coverage for the module resolution system.
packages/packem/__fixtures__/module-conditions/module-and-require/package.json (1)
4-8
: Consider renaming "module-sync" for clarity.The export conditions are well-defined, allowing for both ES module and CommonJS usage. However, the "module-sync" naming is non-standard and might be confusing.
Consider renaming "module-sync" to "import" for better clarity and alignment with common practices. Here's the suggested change:
"exports": { "node": { - "module-sync": "./module.js", + "import": "./module.js", "require": "./require.cjs" }, "default": "./module.js" }This change maintains the functionality while improving readability and adherence to common conventions.
packages/packem/__fixtures__/module-conditions/require-module-import/package.json (1)
4-8
: LGTM: Comprehensive conditional exports for Node.js.The conditional exports for the "node" environment are well-defined, supporting both CommonJS ("require") and ES modules ("module-sync" and "import"). This ensures compatibility with different module systems in Node.js environments.
Consider combining the "module-sync" and "import" conditions since they point to the same file:
"node": { "require": "./require.cjs", "import": "./module.js" }This simplification maintains the same functionality while reducing redundancy.
packages/packem/src/utils/infer-export-type.ts (1)
14-16
: LGTM! Consider adding a comment explaining the "module-sync" condition.The addition of the "module-sync" condition is a logical extension of the function's capabilities. It's correctly implemented and placed at the beginning of the function, giving it precedence over other conditions.
To improve code maintainability, consider adding a brief comment explaining the purpose and origin of the "module-sync" condition. This would be particularly helpful for future maintainers, especially if it's related to the Node.js PR mentioned in the pull request description.
export const inferExportType = (condition: string, previousConditions: string[], packageType: "cjs" | "esm", filename?: string): "cjs" | "esm" => { + // The "module-sync" condition is related to [brief explanation] if (condition === "module-sync") { return "esm"; }
examples/multi-exports/package.json (1)
Line range hint
6-38
: Consider simplifying the export structure and typesVersions field.The current export structure and
typesVersions
field are well-organized but could potentially be simplified:
The export conditions for both the main entry point and the "react" subpath are identical. Consider extracting this structure into a reusable variable or function if your build process supports it.
The
typesVersions
field currently specifies production type definitions. Consider if it's necessary to have separate production type definitions, or if a single set of type definitions could suffice for both development and production.Here's a conceptual example of how you might simplify the exports (note that this is pseudocode and would need to be adapted to your specific build process):
const createExports = (name) => ({ import: { types: `./dist/${name}.d.mts`, development: `./dist/${name}.development.mjs`, production: `./dist/${name}.production.mjs`, default: `./dist/${name}.mjs` }, require: { types: `./dist/${name}.d.cts`, production: `./dist/${name}.production.cjs`, development: `./dist/${name}.development.cjs`, default: `./dist/${name}.cjs` } }); module.exports = { // ... other package.json fields ... exports: { ".": createExports("index"), "./react": createExports("react") }, // ... rest of package.json ... };This approach would make it easier to add new subpaths in the future and reduce the risk of inconsistencies between different export definitions.
Also applies to: 42-50
packages/packem/__tests__/helpers.ts (1)
108-122
: LGTM with suggestions: NewassertContainFiles
function.The function provides a useful abstraction for checking the existence of multiple files. Here are some suggestions for improvement:
- Consider adding error handling for invalid directory paths.
- The function name could be more specific, e.g.,
assertFilesExist
.- Consider returning a boolean instead of using
expect
directly, making it more flexible for different testing scenarios.Here's a potential refactor incorporating these suggestions:
export const assertFilesExist = (directory: string, filePaths: string[]): boolean => { if (!existsSync(directory)) { throw new Error(`Invalid directory path: ${directory}`); } const missingFiles = filePaths.filter((filePath) => { const fullPath = resolve(directory, filePath); // eslint-disable-next-line security/detect-non-literal-fs-filename return !existsSync(fullPath); }); return missingFiles.length === 0; }; // Usage in tests expect(assertFilesExist(directory, filePaths)).toBe(true);This refactored version includes error handling, a more specific name, and returns a boolean for flexibility.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
🔇 Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (41)
- examples/isolated-declarations-oxc/package.json (1 hunks)
- examples/isolated-declarations-swc/package.json (1 hunks)
- examples/multi-exports/package.json (1 hunks)
- examples/react-tsx-css/package.json (1 hunks)
- examples/react-tsx/package.json (1 hunks)
- examples/react-use-client/package.json (1 hunks)
- examples/transformer-esbuild/package.json (1 hunks)
- examples/transformer-sucrase/package.json (1 hunks)
- examples/transformer-swc/package.json (1 hunks)
- package.json (1 hunks)
- packages/packem/fixtures/module-conditions/import-module-require/import.js (1 hunks)
- packages/packem/fixtures/module-conditions/import-module-require/module.js (1 hunks)
- packages/packem/fixtures/module-conditions/import-module-require/package.json (1 hunks)
- packages/packem/fixtures/module-conditions/import-module-require/require.cjs (1 hunks)
- packages/packem/fixtures/module-conditions/module-and-import/import.js (1 hunks)
- packages/packem/fixtures/module-conditions/module-and-import/module.js (1 hunks)
- packages/packem/fixtures/module-conditions/module-and-import/package.json (1 hunks)
- packages/packem/fixtures/module-conditions/module-and-require/module.js (1 hunks)
- packages/packem/fixtures/module-conditions/module-and-require/package.json (1 hunks)
- packages/packem/fixtures/module-conditions/module-and-require/require.cjs (1 hunks)
- packages/packem/fixtures/module-conditions/module-import-require/import.js (1 hunks)
- packages/packem/fixtures/module-conditions/module-import-require/module.js (1 hunks)
- packages/packem/fixtures/module-conditions/module-import-require/package.json (1 hunks)
- packages/packem/fixtures/module-conditions/module-import-require/require.cjs (1 hunks)
- packages/packem/fixtures/module-conditions/module-only/module.js (1 hunks)
- packages/packem/fixtures/module-conditions/module-only/package.json (1 hunks)
- packages/packem/fixtures/module-conditions/module-require-import/import.js (1 hunks)
- packages/packem/fixtures/module-conditions/module-require-import/module.js (1 hunks)
- packages/packem/fixtures/module-conditions/module-require-import/package.json (1 hunks)
- packages/packem/fixtures/module-conditions/module-require-import/require.cjs (1 hunks)
- packages/packem/fixtures/module-conditions/require-module-import/import.js (1 hunks)
- packages/packem/fixtures/module-conditions/require-module-import/module.js (1 hunks)
- packages/packem/fixtures/module-conditions/require-module-import/package.json (1 hunks)
- packages/packem/fixtures/module-conditions/require-module-import/require.cjs (1 hunks)
- packages/packem/tests/helpers.ts (3 hunks)
- packages/packem/tests/intigration/package-json-exports.test.ts (2 hunks)
- packages/packem/package.json (2 hunks)
- packages/packem/src/create-bundler.ts (1 hunks)
- packages/packem/src/rollup/plugins/esbuild/index.ts (0 hunks)
- packages/packem/src/utils/extract-export-filenames.ts (1 hunks)
- packages/packem/src/utils/infer-export-type.ts (1 hunks)
💤 Files not reviewed due to no reviewable changes (1)
- packages/packem/src/rollup/plugins/esbuild/index.ts
🧰 Additional context used
Biome
packages/packem/__fixtures__/module-conditions/module-require-import/require.cjs
[error] 1-1: Illegal use of an export declaration outside of a module
not allowed inside scripts
(parse)
GitHub Check: Test (node-22, ubuntu-latest)
packages/packem/__tests__/intigration/package-json-exports.test.ts
[failure] 1655-1655: tests/intigration/package-json-exports.test.ts > packem package.json exports > should support the new 'module-sync' exports
AssertionError: expected 'const resolved$6 = "module";\n\nconst…' to be 'const resolved$6 = 'module';\n\ncon…' // Object.is equality
- Expected
- Received
- const resolved$6 = 'module';
- const resolved$6 = "module";
- const resolved$5 = 'module';
- const resolved$5 = "module";
- const resolved$4 = 'module';
- const resolved$4 = "module";
- const resolved$3 = 'module';
- const resolved$3 = "module";
- const resolved$2 = 'module';
- const resolved$2 = "module";
- const resolved$1 = 'module';
- const resolved$1 = "module";
- const resolved = 'module';
const resolved = "module";
console.log("import-module-require", resolved$6);
console.log("module-and-import", resolved$5);
console.log("module-and-require", resolved$4);
console.log("module-import-require", resolved$3);
console.log("module-only", resolved$2);
console.log("module-require-import", resolved$1);
console.log("require-module-import", resolved);❯ tests/intigration/package-json-exports.test.ts:1655:21
[failure] 1770-1770: tests/intigration/package-json-exports.test.ts > packem package.json exports > should support the new 'module-sync' exports node
AssertionError: expected 'const resolved$6 = "module";\n\nconst…' to be 'const resolved$6 = 'module';\n\ncon…' // Object.is equality
- Expected
- Received
- const resolved$6 = 'module';
- const resolved$6 = "module";
- const resolved$5 = 'module';
- const resolved$5 = "module";
- const resolved$4 = 'module';
- const resolved$4 = "module";
- const resolved$3 = 'module';
- const resolved$3 = "module";
- const resolved$2 = 'module';
- const resolved$2 = "module";
- const resolved$1 = 'module';
- const resolved$1 = "module";
- const resolved = 'module';
const resolved = "module";
console.log("import-module-require", resolved$6);
console.log("module-and-import", resolved$5);
console.log("module-and-require", resolved$4);
console.log("module-import-require", resolved$3);
console.log("module-only", resolved$2);
console.log("module-require-import", resolved$1);
console.log("require-module-import", resolved);❯ tests/intigration/package-json-exports.test.ts:1770:21
🔇 Additional comments not posted (49)
packages/packem/__fixtures__/module-conditions/module-import-require/require.cjs (1)
1-1
: LGTM! The implementation is correct and serves its purpose.This new file creates a simple CommonJS module that exports a single property
resolved
with the value"require"
. Its location in the__fixtures__
directory and themodule-conditions/module-import-require
path suggest that it's part of a test suite for module import/require behavior. The implementation is straightforward and appropriate for its testing purpose.packages/packem/__fixtures__/module-conditions/require-module-import/require.cjs (1)
1-1
: LGTM! Well-structured test fixture for CommonJS module resolution.This new file is a well-designed test fixture for verifying module resolution in a CommonJS context. The
.cjs
extension clearly indicates its module type, and the single export with a descriptive value ("require") will be useful for asserting correct module loading in tests.The simplicity of this fixture is appropriate for its purpose, making it easy to understand and maintain.
packages/packem/__fixtures__/module-conditions/import-module-require/import.js (1)
1-1
: LGTM! This addition aligns with the PR objectives.The introduction of this constant export serves as a clear identifier for import-related testing in the context of module conditions. This simple yet effective approach contributes to the PR's goal of supporting more special fields of target runtime by providing a mechanism to distinguish between different module formats in test scenarios.
packages/packem/__fixtures__/module-conditions/module-and-import/import.js (1)
1-1
: LGTM! This fixture will be useful for testing module resolution.The code is clean, concise, and serves its purpose well as a test fixture. It exports a constant that clearly identifies its resolution method, which will be valuable for testing different module conditions.
This file, along with potentially other similar files (e.g., for CommonJS), can be used to verify that the bundler correctly handles various module formats and import conditions. It's a good practice to have such fixtures for comprehensive testing of module resolution logic.
packages/packem/__fixtures__/module-conditions/module-and-import/module.js (1)
1-1
: LGTM! This fixture looks good for testing module conditions.The code is simple, clear, and serves its purpose as a test fixture. The exported constant
resolved
with the value "module" can be useful for testing module resolution or condition-based imports in the packem project.Given the PR objectives to "support more special fields of target runtime", this fixture might be part of an expanded test suite to ensure correct handling of different module types or conditions. It aligns well with the goal of enhancing functionality related to target runtime support.
packages/packem/__fixtures__/module-conditions/module-and-require/module.js (1)
1-1
: LGTM! This addition aligns with the PR objectives.The introduction of this module with a single export
resolved
set to "module" is appropriate for testing module conditions. It provides a clear identifier for the ES module version in a dual package scenario, which is relevant to the PR's goal of supporting more special fields for the target runtime.This simple fixture will be useful for verifying the correct resolution of module formats, especially in the context of the enhancements mentioned in the Node.js contribution referenced in the PR description.
packages/packem/__fixtures__/module-conditions/module-import-require/module.js (1)
1-1
: LGTM! Clear and purposeful test fixture.This new file introduces a simple module export, which is well-suited for testing module resolution and import/require conditions. The constant
resolved
with the value "module" provides a clear identifier for the module type, which aligns with the PR's objective of supporting more special fields for the target runtime.packages/packem/__fixtures__/module-conditions/module-only/module.js (1)
1-1
: LGTM! Clear and purposeful test fixture.This single-line module export is well-structured and serves its purpose as a test fixture for module conditions. The constant name
resolved
is descriptive, and the value "module" clearly indicates its intended use in testing module-type exports.packages/packem/__fixtures__/module-conditions/module-require-import/import.js (1)
1-1
: LGTM! This fixture serves its purpose well.The code is simple and effective for its intended use as a test fixture. It exports a constant
resolved
with the value"import"
, which aligns perfectly with testing module resolution for the 'import' condition.This file, located in the
__fixtures__/module-conditions/module-require-import/
directory, is likely part of a broader set of test cases for various module conditions. It will be valuable for ensuring that the bundler correctly handles different module formats and conditions during the build process.packages/packem/__fixtures__/module-conditions/require-module-import/import.js (1)
1-1
: LGTM! This addition enhances the test fixtures for module conditions.The new
import.js
file is a well-structured and purposeful addition to the test fixtures. It exports a single constantresolved
with the value "import", which aligns with its intended use in testing module resolution scenarios.This file, along with potentially other similar files, will likely be used to verify how packem handles different module conditions and import mechanisms. Its simplicity and clear naming convention make it an effective tool for such tests.
packages/packem/__fixtures__/module-conditions/require-module-import/module.js (1)
1-1
: LGTM! Clear and purposeful fixture for module resolution testing.This new file introduces a simple module export, which appears to be part of a test fixture for module conditions. The constant
resolved
with the value "module" is likely used to verify correct module resolution behavior in different contexts.This addition aligns well with the PR objective of supporting more special fields for the target runtime, particularly in the realm of module systems and import/export mechanisms.
packages/packem/__fixtures__/module-conditions/module-only/package.json (1)
1-6
: LGTM! Well-structured module configuration.The
package.json
file is correctly configured for an ES module:
- The
"type": "module"
declaration explicitly sets this as an ES module, which is a good practice for clarity and proper interpretation by Node.js and other tools.- The
exports
field is used effectively to define a specific export condition,"module-sync"
, pointing to"./module.js"
.This configuration provides clear and controlled module exports, which is beneficial for:
- Encapsulation: Only explicitly defined exports are accessible.
- Clarity: The export structure is immediately apparent from the package.json.
- Compatibility: It supports modern JavaScript module systems.
packages/packem/__fixtures__/module-conditions/module-and-import/package.json (3)
2-2
: LGTM: Appropriate module type declaration.The "type": "module" declaration is correct and aligns with modern JavaScript practices for using ECMAScript modules (ESM).
3-9
: LGTM: Well-structured conditional exports.The "exports" field is correctly structured to provide conditional exports, which is a good practice for module resolution in different environments.
8-8
: LGTM: Appropriate default export.The default export is correctly specified, providing a fallback for environments not matching any specific condition. This follows best practices for conditional exports.
packages/packem/__fixtures__/module-conditions/module-and-require/package.json (3)
2-2
: LGTM: Appropriate module type declaration.Setting
"type": "module"
is correct for packages using ECMAScript modules. This allows the use ofimport
andexport
statements without requiring the.mjs
extension.
3-9
: Well-structured conditional exports.The "exports" field is correctly structured to use Node.js conditional exports. This setup allows for:
- Environment-specific entry points (under "node").
- A fallback option (under "default").
This structure enhances the package's flexibility and compatibility across different JavaScript environments.
1-10
: Overall, well-structured package.json for dual module support.This
package.json
file is correctly set up to support both ES modules and CommonJS in a Node.js environment. It uses conditional exports effectively, allowing for flexible module resolution. The only suggested improvement is a minor naming convention change for clarity.Great job on implementing a forward-compatible module structure!
packages/packem/__fixtures__/module-conditions/import-module-require/package.json (4)
2-2
: LGTM: Correct module type declaration.The
"type": "module"
declaration is correct and follows the ECMAScript modules standard. This indicates that the package uses ES modules by default, which is consistent with modern JavaScript practices.
3-10
: LGTM: Well-structured exports field.The exports field is well-structured and follows the Node.js conditional exports syntax. This setup allows for different entry points based on the environment and import method, supporting both CommonJS and ES modules. It's a good practice for ensuring compatibility across different module systems.
9-9
: LGTM: Appropriate default export.The default export is correctly specified and points to "./module.js". This provides a suitable fallback for environments not covered by the specific conditions, ensuring broad compatibility. It's consistent with the "module-sync" condition, which is a good practice.
4-8
: Verify the usage of the non-standard "module-sync" condition.The Node.js specific exports are well-structured and cover different module systems:
- "import" for ES modules
- "require" for CommonJS
However, the "module-sync" condition is non-standard. While it likely serves a specific purpose in your project (possibly for synchronous ES module loading), it's worth verifying its necessity and usage across the project.
Could you provide more context on the usage of the "module-sync" condition? If it's project-specific, consider documenting its purpose in a comment.
To verify its usage, you can run the following script:
✅ Verification successful
The usage of the non-standard "module-sync" condition is consistent across the codebase and does not introduce any issues. Consider documenting its purpose for better clarity.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for usage of the "module-sync" condition in the project # Search for "module-sync" in JavaScript files echo "Searching for 'module-sync' usage in JS files:" rg --type js "module-sync" -C 3 # Search for "module-sync" in package.json files echo "Searching for 'module-sync' in package.json files:" rg --type json "module-sync" -C 3Length of output: 5349
packages/packem/__fixtures__/module-conditions/module-import-require/package.json (3)
2-2
: LGTM: Correct module type declaration.The "type" field is correctly set to "module", indicating that this package uses ECMAScript modules. This is consistent with modern JavaScript practices and allows the use of import/export syntax.
3-10
: LGTM: Well-structured exports field.The "exports" field is well-structured, providing conditional exports for Node.js environments and a default export. This setup allows for better compatibility across different module systems (ESM and CommonJS) and environments.
5-5
: Verify the usage of "module-sync" condition.The "module-sync" condition is not a standard Node.js condition. While custom conditions are allowed, it's important to ensure that this condition is intentional and properly handled in the codebase.
To verify the usage of this condition, please run the following script:
If there are no matches, consider removing this condition or documenting its purpose.
packages/packem/__fixtures__/module-conditions/module-require-import/package.json (4)
2-2
: LGTM: Correct module type declaration.The
"type": "module"
declaration is correct and follows the ECMAScript modules standard. This indicates that the package uses ES modules by default, which is consistent with modern JavaScript practices.
3-10
: LGTM: Well-structured exports field.The exports field is correctly structured according to the Node.js package exports specification. This setup allows for conditional exports based on different environments and import methods, which is a good practice for ensuring compatibility across various module systems.
9-9
: LGTM: Correct default export specification.The default export is correctly specified, pointing to "./module.js". This provides a suitable fallback for environments that don't match any of the conditional exports, ensuring broad compatibility.
1-11
: Summary: Well-structured package.json supporting multiple module systems.This new
package.json
file effectively supports the PR objective of "fix: support more special fields of target runtime". It defines conditional exports for different module systems, aligning with modern JavaScript practices and Node.js specifications. The structure allows for compatibility with both CommonJS and ES modules, which is crucial for broad runtime support.Key points:
- Correct module type declaration as "module".
- Well-structured exports field with conditional exports.
- Support for both "require" (CommonJS) and "import" (ES modules) conditions.
- A default export for fallback compatibility.
The only point requiring clarification is the non-standard "module-sync" condition, which should be explained or documented for clarity.
Overall, this file contributes positively to the project's goal of enhancing support for special fields in the target runtime.
packages/packem/__fixtures__/module-conditions/require-module-import/package.json (3)
2-2
: LGTM: Correct module type declaration.The
"type": "module"
declaration is correct and follows the ECMAScript modules standard. This indicates that the package uses ES modules by default, which is a good practice for modern JavaScript development.
3-10
: LGTM: Well-structured exports field.The exports field is well-structured and follows the Node.js conditional exports syntax. This setup allows for different entry points based on the environment and import method, which is a good practice for ensuring compatibility across different module systems.
9-9
: LGTM: Appropriate default export.The default export to "./module.js" is correctly defined, providing a fallback for environments that don't match the "node" condition. This ensures that the module can be used in various JavaScript environments.
To ensure the referenced files exist, run the following script:
This script will list all .cjs and .js files in the directory, allowing you to verify that both
require.cjs
andmodule.js
exist.✅ Verification successful
Verified: Default export is correctly defined and the target file exists.
The default export to
./module.js
has been successfully verified. Themodule.js
file exists in the specified directory, ensuring that environments not matching the "node" condition have a valid fallback.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the existence of files referenced in package.json # Test: Check if the referenced files exist fd -t f -e cjs -e js -d 1 . packages/packem/__fixtures__/module-conditions/require-module-importLength of output: 337
examples/isolated-declarations-swc/package.json (1)
36-36
: Dependency version update looks good.The
@swc/core
dependency has been updated from^1.7.26
to^1.7.28
. This is a minor version update, which typically includes backwards-compatible new features or bug fixes. The update aligns with good practices of keeping dependencies up-to-date.To ensure this update doesn't introduce any breaking changes or conflicts, please run the following verification script:
Make sure to review the output of these commands to confirm that the update doesn't introduce any issues.
examples/isolated-declarations-oxc/package.json (1)
38-38
: Version update foroxc-transform
looks good.The update of
oxc-transform
from^0.30.0
to^0.30.1
is a minor version bump, which typically indicates backward-compatible bug fixes or small improvements. This change aligns with good practices for keeping dependencies up-to-date.To ensure this update doesn't introduce any breaking changes or conflicts, please run the following verification script:
examples/transformer-esbuild/package.json (3)
Line range hint
36-37
: Verify React versionThe specified React version (
^18.3.1
) seems unusually high. As of my last update, the latest stable version of React is in the 18.2.x range. This could potentially lead to compatibility issues or indicate a typo in the version number.Let's verify the latest available React version:
#!/bin/bash # Description: Check the latest available React version # Test: Query npm for the latest React version npm view react versionPlease ensure that the React version specified is correct and compatible with your project requirements.
43-43
: Consider esbuild versionThe specified esbuild version (
^0.24.0
) appears to be ahead of the current latest stable version, which is in the 0.19.x range as of my last update. While using cutting-edge versions can provide access to new features, it may also introduce instability or breaking changes.Let's verify the latest stable version of esbuild:
#!/bin/bash # Description: Check the latest stable esbuild version # Test: Query npm for the latest esbuild version npm view esbuild versionConsider whether using a potentially unstable version of esbuild is necessary for your project, or if a more stable version would be more appropriate.
40-40
: LGTM: @types/react version updateThe update of
@types/react
from^18.3.8
to^18.3.9
is a minor version bump, which typically includes bug fixes and small improvements. This change is generally safe and helps keep the project up-to-date with the latest type definitions for React.To ensure consistency across the project, let's verify if other React-related packages are up-to-date:
This will help identify if there are any inconsistencies in React-related package versions across the project.
✅ Verification successful
@types/react version update verified
All instances of
@types/react
have been successfully updated to^18.3.9
across the project, ensuring consistency in type definitions.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check versions of React-related packages in package.json files # Test: Search for React-related package versions in all package.json files rg --type json -g 'package.json' '"react.*": "\^18\.'Length of output: 1286
Script:
#!/bin/bash # Description: Check versions of @types/react in all package.json files rg --type json -g 'package.json' '"@types/react": "\^18\.[0-9]+\.[0-9]+"'Length of output: 647
examples/transformer-sucrase/package.json (1)
40-40
: Version update for @types/react looks good.The update of
@types/react
from^18.3.8
to^18.3.9
is a minor version bump, which typically indicates backward-compatible bug fixes or small improvements. This update is likely beneficial for the project.However, to ensure consistency, consider the following:
The
react
package itself is at version^18.3.1
. It's generally a good practice to keep the types version in sync with the actual package version. You might want to consider updatingreact
to^18.3.9
as well if available.The
react-dom
package and its types (@types/react-dom
) are also present in the dependencies. It's often recommended to keep these in sync with the React version. Consider updating these if newer compatible versions are available.To verify the latest available versions and potential updates, you can run the following script:
This script will help you ensure all React-related packages are up-to-date and compatible.
✅ Verification successful
@types/react update verified and up to date.
All React-related packages (
react
,@types/react
,react-dom
,@types/react-dom
) are current, and no removed or replaced code was detected.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check latest versions for react-related packages echo "Current package versions:" npm ls react @types/react react-dom @types/react-dom echo "\nLatest available versions:" npm view react @types/react react-dom @types/react-dom version echo "\nChecking for updates:" npm outdated react @types/react react-dom @types/react-domLength of output: 579
Script:
#!/bin/bash # Description: Retrieve current and latest versions for react-related packages without using npm # Extract current versions from package.json echo "Current package versions:" CURRENT_REACT=$(jq -r '.dependencies.react // .devDependencies.react' examples/transformer-sucrase/package.json) CURRENT_TYPES_REACT=$(jq -r '.dependencies["@types/react"] // .devDependencies["@types/react"]' examples/transformer-sucrase/package.json) CURRENT_REACT_DOM=$(jq -r '.dependencies.react-dom // .devDependencies.react-dom' examples/transformer-sucrase/package.json) CURRENT_TYPES_REACT_DOM=$(jq -r '.dependencies["@types/react-dom"] // .devDependencies["@types/react-dom"]' examples/transformer-sucrase/package.json) echo "react: $CURRENT_REACT" echo "@types/react: $CURRENT_TYPES_REACT" echo "react-dom: $CURRENT_REACT_DOM" echo "@types/react-dom: $CURRENT_TYPES_REACT_DOM" # Function to fetch latest version from npm registry get_latest_version() { PACKAGE=$1 VERSION=$(curl -s "https://registry.npmjs.org/$PACKAGE" | jq -r '.["dist-tags"].latest') echo "$VERSION" } # Fetch latest versions echo -e "\nLatest available versions:" LATEST_REACT=$(get_latest_version react) LATEST_TYPES_REACT=$(get_latest_version @types/react) LATEST_REACT_DOM=$(get_latest_version react-dom) LATEST_TYPES_REACT_DOM=$(get_latest_version @types/react-dom) echo "react: $LATEST_REACT" echo "@types/react: $LATEST_TYPES_REACT" echo "react-dom: $LATEST_REACT_DOM" echo "@types/react-dom: $LATEST_TYPES_REACT_DOM" # Compare current and latest versions echo -e "\nChecking for updates:" compare_version() { CURRENT=$1 LATEST=$2 PACKAGE=$3 if [ "$CURRENT" != "$LATEST" ]; then echo "$PACKAGE: Current version is $CURRENT, latest version is $LATEST" else echo "$PACKAGE: Up to date" fi } compare_version "$CURRENT_REACT" "$LATEST_REACT" "react" compare_version "$CURRENT_TYPES_REACT" "$LATEST_TYPES_REACT" "@types/react" compare_version "$CURRENT_REACT_DOM" "$LATEST_REACT_DOM" "react-dom" compare_version "$CURRENT_TYPES_REACT_DOM" "$LATEST_TYPES_REACT_DOM" "@types/react-dom"Length of output: 3313
Script:
#!/bin/bash # Description: Retrieve current and latest versions for react-related packages without using npm # Extract current versions from package.json echo "Current package versions:" CURRENT_REACT=$(jq -r '.dependencies["react"] // .devDependencies["react"]' examples/transformer-sucrase/package.json) CURRENT_TYPES_REACT=$(jq -r '.dependencies["@types/react"] // .devDependencies["@types/react"]' examples/transformer-sucrase/package.json) CURRENT_REACT_DOM=$(jq -r '.dependencies["react-dom"] // .devDependencies["react-dom"]' examples/transformer-sucrase/package.json) CURRENT_TYPES_REACT_DOM=$(jq -r '.dependencies["@types/react-dom"] // .devDependencies["@types/react-dom"]' examples/transformer-sucrase/package.json) echo "react: $CURRENT_REACT" echo "@types/react: $CURRENT_TYPES_REACT" echo "react-dom: $CURRENT_REACT_DOM" echo "@types/react-dom: $CURRENT_TYPES_REACT_DOM" # Function to fetch latest version from npm registry get_latest_version() { PACKAGE=$1 VERSION=$(curl -s "https://registry.npmjs.org/$PACKAGE" | jq -r '.["dist-tags"].latest') echo "$VERSION" } # Fetch latest versions echo -e "\nLatest available versions:" LATEST_REACT=$(get_latest_version react) LATEST_TYPES_REACT=$(get_latest_version @types/react) LATEST_REACT_DOM=$(get_latest_version react-dom) LATEST_TYPES_REACT_DOM=$(get_latest_version @types/react-dom) echo "react: $LATEST_REACT" echo "@types/react: $LATEST_TYPES_REACT" echo "react-dom: $LATEST_REACT_DOM" echo "@types/react-dom: $LATEST_TYPES_REACT_DOM" # Compare current and latest versions echo -e "\nChecking for updates:" compare_version() { CURRENT=$1 LATEST=$2 PACKAGE=$3 # Remove any leading ^ or ~ from CURRENT version CLEAN_CURRENT=$(echo "$CURRENT" | sed 's/^[\^~]//') if [ "$CLEAN_CURRENT" != "$LATEST" ]; then echo "$PACKAGE: Current version is $CURRENT, latest version is $LATEST" else echo "$PACKAGE: Up to date" fi } compare_version "$CURRENT_REACT" "$LATEST_REACT" "react" compare_version "$CURRENT_TYPES_REACT" "$LATEST_TYPES_REACT" "@types/react" compare_version "$CURRENT_REACT_DOM" "$LATEST_REACT_DOM" "react-dom" compare_version "$CURRENT_TYPES_REACT_DOM" "$LATEST_TYPES_REACT_DOM" "@types/react-dom"Length of output: 2970
examples/transformer-swc/package.json (1)
40-42
: LGTM! Consider verifying the impact of dependency updates.The updates to
@swc/core
(^1.7.28) and@types/react
(^18.3.9) are minor version increments, which is generally a good practice for keeping dependencies up-to-date. These updates likely include bug fixes, performance improvements, or new features.To ensure these updates don't introduce any unexpected changes, please run the following verification steps:
- Rebuild the project and run tests (if available) to check for any breaking changes.
- Review the changelogs of both packages to understand what's new:
examples/react-tsx/package.json (1)
40-40
: Version update for @types/react looks good.The update of
@types/react
from^18.3.8
to^18.3.9
is a minor version bump, which is generally safe and brings in the latest type definitions for React. This update is likely to include bug fixes or small improvements in the type definitions.However, let's verify if this update is consistent with the other React-related dependencies in this file.
✅ Verification successful
@types/react-dom version is consistent.
The current version of
@types/react-dom
(^18.3.0
) aligns well with the React dependencies (^18.3.1
). The minor version difference is acceptable and should not introduce any compatibility issues.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check versions of React-related dependencies for consistency echo "React version:" jq '.dependencies.react' examples/react-tsx/package.json echo "React DOM version:" jq '.dependencies["react-dom"]' examples/react-tsx/package.json echo "@types/react-dom version:" jq '.devDependencies["@types/react-dom"]' examples/react-tsx/package.jsonLength of output: 375
examples/react-use-client/package.json (1)
42-42
: Approved minor update, but consider version alignment.The update of
@types/react
from^18.3.8
to^18.3.9
is a minor version change and is generally safe. However, there are a couple of points to consider:
There's a potential mismatch between
@types/react
(18.x) and the actual React version (19.0.0-rc) used in the dependencies. It's important to ensure that the type definitions are compatible with the React version in use.The use of a release candidate version (19.0.0-rc-eb3ad065-20240822) for both
react
andreact-dom
in the dependencies is unusual for a production environment. Consider using stable versions unless there's a specific need for the release candidate features.To ensure compatibility, please run the following script:
This script will help identify any potential version mismatches across the project and highlight the usage of release candidate versions.
examples/multi-exports/package.json (1)
61-61
: Approve the @types/react version update.The update of
@types/react
from^18.3.8
to^18.3.9
is a minor version bump, which typically includes bug fixes and small improvements. This update is likely beneficial for the project as it provides the latest type definitions for React.To ensure this update doesn't introduce any incompatibilities, let's verify the versions of related dependencies:
✅ Verification successful
@types/react version update is compatible and approved.
The update of@types/react
to^18.3.9
is compatible with the currentreact
andreact-dom
versions (^18.3.1
) in the project. No additional dependency updates are required at this time.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check versions of react and react-dom to ensure compatibility # Test: Search for react and react-dom versions in package.json files rg --type json '"react": "(\^18|\d+)' ./examples rg --type json '"react-dom": "(\^18|\d+)' ./examplesLength of output: 1054
packages/packem/__tests__/helpers.ts (1)
11-11
: LGTM: Import statement for Vitest'sexpect
function.The import of
expect
from 'vitest' is correctly placed and necessary for the newassertContainFiles
function.package.json (1)
71-72
: Dependency updates look good, but require verification.The updates to "nx" (^19.8.0 to ^19.8.1) and "pkg-pr-new" (^0.0.25 to ^0.0.27) appear to be minor version increments, which is generally safe. However, I recommend the following actions:
For "nx", please verify the changelog for version 19.8.1 to ensure there are no breaking changes that might affect your build process.
Regarding "pkg-pr-new", could you provide more information about its purpose in the project and the reason for this update? This will help ensure the update aligns with the PR objectives.
To check the changelog for nx, you can run:
This will help verify if there are any significant changes or potential impacts on the project.
✅ Verification successful
Dependency updates verified and approved.
- The "nx" update (^19.8.0 to ^19.8.1) introduces minor features and fixes without breaking changes, as confirmed by the changelog.
- The "pkg-pr-new" update (^0.0.25 to ^0.0.27) is used solely in the CI scripts for publishing packages and poses no issues.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Fetch the changelog for nx version 19.8.1 gh release view 19.8.1 --repo nrwl/nxLength of output: 2331
Script:
#!/bin/bash # Get details of 'pkg-pr-new' from package.json jq '.dependencies["pkg-pr-new"]' package.json # Find where 'pkg-pr-new' is used in the codebase rg 'pkg-pr-new' --context 2Length of output: 1597
packages/packem/package.json (3)
211-211
: LGTM: Minor version update for @rollup/plugin-node-resolveThe update from version 15.2.4 to 15.3.0 for
@rollup/plugin-node-resolve
is a minor version bump, which typically includes new features or non-breaking changes. This update aligns with semantic versioning principles and is generally a good practice to keep dependencies up-to-date.To ensure there are no unexpected changes, please review the changelog for
@rollup/plugin-node-resolve
between versions 15.2.4 and 15.3.0. You can find the changelog at: https://github.com/rollup/plugins/blob/master/packages/node-resolve/CHANGELOG.md
254-254
: LGTM: Patch version update for @swc/coreThe update from version ^1.7.26 to ^1.7.28 for
@swc/core
is a patch version bump, which typically includes bug fixes and minor improvements. This update maintains backward compatibility and is a good practice for keeping dependencies secure and bug-free.To ensure you're aware of any bug fixes or improvements, please review the changelog for
@swc/core
between versions 1.7.26 and 1.7.28. You can find the changelog at: https://github.com/swc-project/swc/blob/main/CHANGELOG.md
262-262
: LGTM: Patch version update for @types/reactThe update from version ^18.3.8 to ^18.3.9 for
@types/react
is a patch version bump for the TypeScript type definitions of React. This update maintains backward compatibility and is important for accurate TypeScript checking and IDE support.To ensure compatibility, please verify that this version of
@types/react
is compatible with the version of React used in your project. You can check this by running the following command in your project root:This will show the installed versions of both packages. Ensure that the major and minor versions align (e.g., React 18.x.x with @types/react 18.x.x).
packages/packem/src/create-bundler.ts (2)
Line range hint
1-1037
: Overall, the changes look good, but some additional context would be helpful.The addition of the
exportConditions
property to theresolve
object in thegenerateOptions
function is the only change in this file. While the change itself is straightforward and likely intentional, it would be beneficial to provide more context about its purpose and potential impacts on the bundling process. Consider adding a comment to explain why the "module-sync" condition was added and how it affects module resolution.The rest of the file remains unchanged, and the overall structure and functionality appear to be intact. However, it's important to ensure that this change doesn't have unintended consequences on the module resolution process in other parts of the codebase.
226-226
: LGTM. Consider adding a comment explaining the purpose of this new condition.The addition of
exportConditions: ["module-sync"]
to theresolve
object is approved. This change likely affects how modules are resolved during the bundling process. However, it would be beneficial to add a comment explaining the specific purpose of the "module-sync" condition and any potential impacts on module resolution behavior.To ensure this change doesn't unexpectedly affect module resolution in other parts of the codebase, let's verify its usage:
✅ Verification successful
Verified: Addition of
exportConditions: ["module-sync"]
is consistent with existing codebase usage.The
exportConditions: ["module-sync"]
addition aligns with its usage across utility functions and integration tests. To maintain clarity, please add a comment explaining the purpose and impact of the "module-sync" condition within the bundler configuration.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for other occurrences of 'exportConditions' or 'module-sync' rg --type typescript -i '(exportConditions|"module-sync")'Length of output: 95
Script:
#!/bin/bash # Search for other occurrences of 'exportConditions' or 'module-sync' in TypeScript files rg --type ts -i '(exportConditions|"module-sync")'Length of output: 1024
packages/packem/__fixtures__/module-conditions/module-require-import/package.json
Show resolved
Hide resolved
packages/packem/__tests__/intigration/package-json-exports.test.ts
Outdated
Show resolved
Hide resolved
packages/packem/__tests__/intigration/package-json-exports.test.ts
Outdated
Show resolved
Hide resolved
…em [1.0.3](https://github.com/visulima/packem/compare/@visulima/packem@1.0.2...@visulima/packem@1.0.3) (2024-09-25) ### Bug Fixes * support more special fields of target runtime ([#22](#22)) ([827da5e](827da5e))
Added support for nodejs/node#54648
Summary by CodeRabbit
New Features
package.json
files.Bug Fixes
Tests
Chores