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

fix: fix path resolve warning #258

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

cycleccc
Copy link
Owner

@cycleccc cycleccc commented Oct 16, 2024

Changes Overview

Implementation Approach

Testing Done

Verification Steps

Additional Notes

Checklist

  • I have created a changeset for this PR if necessary.
  • My changes do not break the library.
  • I have added tests where applicable.
  • I have followed the project guidelines.
  • I have fixed any lint issues.

Related Issues

Summary by CodeRabbit

  • Bug Fixes

    • Resolved path resolution warnings across various modules.
  • New Features

    • Added direct import capability for CSS files from multiple packages, enhancing styling accessibility.
  • Chores

    • Updated TypeScript configuration to improve module resolution for better development experience.

@cycleccc cycleccc linked an issue Oct 16, 2024 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Oct 16, 2024

Walkthrough

This pull request introduces a series of patches across multiple modules within the @wangeditor-next package, primarily addressing path resolution warnings. Changes include updates to the package.json files for various modules to add a new CSS export, enabling direct imports of styles. Additionally, the tsconfig.json file has been modified to enhance module resolution by including both src and dist directories in the paths configuration.

Changes

File(s) Change Summary
.changeset/brown-pots-remain.md Introduced patches to fix path resolution warnings and updated package.json to add CSS export.
@wangeditor-next/basic-modules/package.json, @wangeditor-next/code-highlight/package.json, @wangeditor-next/core/package.json, @wangeditor-next/editor/package.json, @wangeditor-next/list-module/package.json, @wangeditor-next/table-module/package.json, @wangeditor-next/upload-image-module/package.json, @wangeditor-next/video-module/package.json, @wangeditor-next/yjs-for-react/package.json, @wangeditor-next/yjs/package.json Added export for "./dist/css/style.css" in package.json.
tsconfig.json Updated compilerOptions.paths to include "packages/*/dist" for @wangeditor-next/*.

Possibly related PRs

  • fix(text): text tag list #199: This PR enhances compatibility with nested tags, which may relate to the overall improvements in module functionality and style handling in the main PR.
  • fix: editor package add peer dependencies #242: The updates in the @wangeditor-next/editor package, including changes to package.json, align with the modifications made in the main PR regarding package exports and structure.
  • 163 bug只读模式下无法复制文本内容 #251: The patch for the @wangeditor-next/core package addresses functionality that could be impacted by the path resolution changes in the main PR, particularly in how modules interact with the editor's features.

Poem

In the garden where code does bloom,
Fixing paths to clear the gloom.
CSS now flows with ease,
Modules dance in the gentle breeze.
Hops and skips, all in delight,
Wangeditor shines, oh what a sight! 🐇✨


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Outside diff range and nitpick comments (6)
tsconfig.json (1)

26-27: LGTM! Consider documenting the resolution order.

The addition of "packages/*/dist" to the path resolution for @wangeditor-next/* modules is a good improvement. It allows TypeScript to resolve modules from both src and dist directories, which is beneficial for development and testing of built packages.

Consider adding a comment in the tsconfig.json file to explain the resolution order (src before dist) to prevent potential confusion for other developers.

Example:

"paths": {
  "@wangeditor-next/*": [
    "packages/*/src",   // Prioritize source files for development
    "packages/*/dist"   // Fall back to built files if needed
  ]
}
packages/list-module/package.json (1)

Line range hint 51-56: Consider using version ranges for peerDependencies.

The current peerDependencies section uses exact version numbers, which might be too restrictive and could lead to compatibility issues as the project evolves. Consider using version ranges (e.g., "^1.7.10" instead of "1.7.10") to allow for minor updates and patches.

Here's a suggested change:

   "peerDependencies": {
-    "@wangeditor-next/core": "1.7.10",
+    "@wangeditor-next/core": "^1.7.10",
     "dom7": "^3.0.0",
-    "slate": "^0.72.0",
+    "slate": "^0.72.0",
     "snabbdom": "^3.1.0"
   }

This change allows for more flexibility in dependency management while still ensuring compatibility.

packages/upload-image-module/package.json (1)

Line range hint 52-59: Consider using version ranges for peer dependencies

The peerDependencies section currently specifies exact versions for dependencies. It's generally recommended to use version ranges (e.g., ^2.0.3 instead of 2.0.3) for peer dependencies to allow for more flexibility and easier updates.

Here's a suggested change:

   "peerDependencies": {
-    "@uppy/core": "^2.0.3",
-    "@uppy/xhr-upload": "^2.0.3",
-    "@wangeditor-next/basic-modules": "1.5.9",
-    "@wangeditor-next/core": "1.7.10",
-    "dom7": "^3.0.0",
-    "lodash.foreach": "^4.5.0",
-    "slate": "^0.72.0",
-    "snabbdom": "^3.1.0"
+    "@uppy/core": "^2.0.3",
+    "@uppy/xhr-upload": "^2.0.3",
+    "@wangeditor-next/basic-modules": "^1.5.9",
+    "@wangeditor-next/core": "^1.7.10",
+    "dom7": "^3.0.0",
+    "lodash.foreach": "^4.5.0",
+    "slate": "^0.72.0",
+    "snabbdom": "^3.1.0"
   }

This change allows for minor updates and patches, which can include bug fixes and non-breaking changes, without requiring updates to this package.json file.

packages/yjs/package.json (1)

Line range hint 1-70: Consider updating package version and reviewing peerDependencies.

While the change is minor, it does affect the package's exports. Consider if this warrants a version bump (e.g., patch version update).

Also, please review the peerDependencies, especially the @wangeditor-next/core version, to ensure it's still compatible with this change.

packages/editor/package.json (2)

Line range hint 15-15: Consider simplifying the types field path

The types field currently points to "dist/editor/src/index.d.ts". This path seems unusually nested. Typically, the types declaration file would be located directly in the dist folder.

Consider simplifying this to "dist/index.d.ts" if possible, ensuring it matches the actual location of your TypeScript declaration file:

- "types": "dist/editor/src/index.d.ts",
+ "types": "dist/index.d.ts",

Please verify that this change doesn't break type declarations for consumers of your package.


22-22: Remove unnecessary blank line in exports field

There's an empty line within the exports object. While this doesn't affect functionality, removing it would improve the JSON structure's cleanliness.

Consider removing this blank line:

  "exports": {
    ".": {
      "types": "./dist/editor/src/index.d.ts",
-
      "import": "./dist/index.mjs",
      "require": "./dist/index.js"
    },
    "./dist/css/style.css": "./dist/css/style.css"
  },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between efd8670 and 0aa3cdd.

📒 Files selected for processing (12)
  • .changeset/brown-pots-remain.md (1 hunks)
  • packages/basic-modules/package.json (1 hunks)
  • packages/code-highlight/package.json (1 hunks)
  • packages/core/package.json (1 hunks)
  • packages/editor/package.json (1 hunks)
  • packages/list-module/package.json (1 hunks)
  • packages/table-module/package.json (1 hunks)
  • packages/upload-image-module/package.json (1 hunks)
  • packages/video-module/package.json (1 hunks)
  • packages/yjs-for-react/package.json (1 hunks)
  • packages/yjs/package.json (1 hunks)
  • tsconfig.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/brown-pots-remain.md
🧰 Additional context used
🔇 Additional comments (10)
packages/video-module/package.json (2)

15-19: Excellent addition of CSS export!

The new export entry for the CSS file is a great improvement. It allows users to directly import the styles associated with the video module, which is in line with modern JavaScript module practices. This change enhances the usability of the package and provides a cleaner way for consumers to include necessary styles.


Line range hint 2-2: Consider version bump and verify peerDependencies

  1. Given the addition of the new CSS export, it might be appropriate to bump the version number. Please consider if this change warrants a version update according to your versioning strategy.

  2. Verify if the peerDependency on @wangeditor-next/core (currently at "1.7.10") needs to be updated. Ensure it's compatible with any recent changes in the core package that might be related to this PR.

To help verify the @wangeditor-next/core version, you can run the following script:

Also applies to: 54-54

packages/code-highlight/package.json (3)

15-15: LGTM: Improved readability

The addition of this empty line enhances the readability of the exports object by separating the types field from the import and require fields.


18-18: LGTM: Enhanced structure

The addition of this empty line improves the structure of the exports object by clearly separating the main export from the new CSS export.


15-19: Summary: Improved package exports and readability

These changes enhance the @wangeditor-next/code-highlight package in two ways:

  1. Improved readability: The addition of empty lines (15, 18) improves the structure and readability of the exports object.
  2. Enhanced functionality: The new CSS export (line 19) allows direct importing of styles, which significantly improves the package's usability.

These updates align the package with modern JavaScript practices and should make it easier for developers to use the code highlighting feature, including its styles.

packages/upload-image-module/package.json (1)

Line range hint 1-59: Summary of review

The changes to this package.json file are appropriate and align with the PR objectives. The addition of the CSS export is a positive change that should resolve path resolve warnings and improve module usage.

A minor suggestion was made regarding the use of version ranges for peer dependencies, but this is not directly related to the main PR objective and can be addressed in a future update if desired.

Overall, the changes look good and can be approved.

packages/basic-modules/package.json (1)

Line range hint 1-67: Consider addressing potential inconsistencies in package.json.

While reviewing the entire file, I noticed a few points that might need attention:

  1. The types field (line 9) points to dist/basic-modules/src/index.d.ts. This path seems unusual as it includes both dist and src. Typically, declaration files are in the dist folder only.

  2. In the exports field, the types entry (line 15) differs from the main types field. It points to ./dist/packages/basic-modules/src/index.d.ts, which has an extra packages in the path.

  3. Given that this change adds a new export, consider if the package version (currently 1.5.9) needs to be updated.

Consider applying these changes:

-  "types": "dist/basic-modules/src/index.d.ts",
+  "types": "dist/index.d.ts",
   "exports": {
     ".": {
-      "types": "./dist/packages/basic-modules/src/index.d.ts",
+      "types": "./dist/index.d.ts",

Also, please review if the version number needs to be updated.

Let's verify the correct location of the type declaration file:

#!/bin/bash
# Check for the existence of type declaration files

echo "Searching for index.d.ts files in the dist directory:"
find packages/basic-modules/dist -name "index.d.ts"

echo "Checking the content of the found index.d.ts files:"
find packages/basic-modules/dist -name "index.d.ts" -exec echo {} \; -exec head -n 5 {} \;
packages/yjs/package.json (1)

26-26: LGTM! Good addition for CSS export.

The new export for the CSS file is a positive change. It allows for direct imports of styles, which is a good practice for modular CSS management and aligns with the PR objective of fixing path resolve warnings.

To ensure the CSS file exists, please run the following script:

✅ Verification successful

CSS File Verified Successfully

The CSS file exists at the specified path, confirming that the new export in package.json is correctly implemented and aligns with the PR objectives.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the CSS file

# Test: Check if the CSS file exists
if fd -p "packages/yjs/dist/css/style.css"; then
    echo "CSS file exists."
else
    echo "Warning: CSS file not found at the specified path."
fi

Length of output: 82

packages/core/package.json (1)

19-19: LGTM! This change enhances package functionality.

The addition of the CSS file export is a good improvement. It allows users to directly import the styles, which aligns with modern JavaScript module systems and improves the overall developer experience.

This change also addresses the path resolve warning mentioned in the PR objectives, contributing to the stability of the package.

packages/editor/package.json (1)

26-26: LGTM: CSS export added correctly

The new export "./dist/css/style.css": "./dist/css/style.css" has been added correctly to the exports field. This change allows users to import the CSS file directly, which aligns with the PR objective of fixing path resolve warnings.

This addition enhances the module's usability by providing a clear way to import the associated styles. It's a good practice for packages that include CSS alongside JavaScript.

"import": "./dist/index.mjs",
"require": "./dist/index.js"
}
},
"./dist/css/style.css": "./dist/css/style.css"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

⚠️ Issue: CSS file and dist directory not found

The CSS file ./dist/css/style.css does not exist at the specified path packages/list-module/dist/css/style.css. Additionally, the dist directory is missing.

Please verify that the build process correctly generates the dist directory and the necessary CSS files.

🔗 Analysis chain

LGTM: CSS file export added correctly.

The addition of "./dist/css/style.css": "./dist/css/style.css" to the exports field is correct and aligns with the PR objective of fixing path resolve warnings. This change allows direct imports of the CSS file, which can improve the module's usability.

To ensure the CSS file exists and the path is correct, please run the following script:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the CSS file and its correct location

# Test: Check if the CSS file exists
if [ -f "packages/list-module/dist/css/style.css" ]; then
    echo "CSS file exists at the specified path."
else
    echo "Warning: CSS file not found at packages/list-module/dist/css/style.css"
fi

# Test: Check if there are any other CSS files in the dist directory that should be exported
css_files=$(find packages/list-module/dist -name "*.css")
if [ "$(echo "$css_files" | wc -l)" -gt 1 ]; then
    echo "Note: Multiple CSS files found in dist directory. Ensure all necessary files are exported:"
    echo "$css_files"
fi

Length of output: 363

Comment on lines +15 to +19

"import": "./dist/index.mjs",
"require": "./dist/index.js"
}
},
"./dist/css/style.css": "./dist/css/style.css"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Issue: CSS file does not exist at the specified path.

The verification script indicates that packages/table-module/dist/css/style.css is missing. Please ensure that the CSS file is generated and correctly placed at this location before adding the export to package.json.

🔗 Analysis chain

Approve the addition of CSS export with verification.

The addition of the CSS export "./dist/css/style.css": "./dist/css/style.css" is a positive change that allows users to import the module's styles directly. This aligns with modern JavaScript module practices and can improve the ease of use of the module.

Please run the following script to verify the existence of the CSS file:

Consider updating the module's documentation to reflect this new export option, providing examples of how users can import and use the CSS file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the CSS file and its contents

# Test: Check if the CSS file exists
if [ -f "packages/table-module/dist/css/style.css" ]; then
    echo "CSS file exists."
    # Display the first few lines of the CSS file
    head -n 5 "packages/table-module/dist/css/style.css"
else
    echo "Error: CSS file does not exist at the specified path."
fi

Length of output: 170

"import": "./dist/index.mjs",
"require": "./dist/index.js"
}
},
"./dist/css/style.css": "./dist/css/style.css"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Issue Detected: CSS File Not Generated for code-highlight

The dist/css/style.css file for the code-highlight package is not being generated because the Rollup configuration does not include CSS processing steps.

Recommended Actions:

  • Update packages/code-highlight/rollup.config.js to include the postcss plugin. This should align it with the shared Rollup configurations that handle CSS processing.
  • Ensure that the postcss configuration correctly extracts the CSS to the dist/css directory.
🔗 Analysis chain

LGTM: Added CSS export

The addition of the CSS file export is a valuable improvement. It allows users to directly import the styles, enhancing the module's usability and aligning with modern JavaScript practices.

To ensure this change is fully implemented, please verify:

  1. The CSS file exists at the specified path.
  2. The build process correctly generates and places the CSS file in the dist folder.

You can use the following script to check the file's existence:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the CSS file exists in the expected location
if [ -f "packages/code-highlight/dist/css/style.css" ]; then
    echo "CSS file exists at the expected location."
else
    echo "CSS file not found at the expected location."
fi

Length of output: 154


Script:

#!/bin/bash
# Search for all CSS source files in the repository
fd --extension css --type f

Length of output: 177


Script:

#!/bin/bash
# Inspect build scripts for CSS processing steps
rg --ignore-case "css" scripts/

Length of output: 80


Script:

#!/bin/bash
# Search for CSS processing steps in package.json scripts
jq '.scripts | to_entries[] | select(.value | test("css"; "i"))' package.json

Length of output: 79


Script:

#!/bin/bash
# Search for CSS-related dependencies in package.json
jq '.dependencies, .devDependencies | to_entries[] | select(.key | test("css"; "i"))' package.json

Length of output: 247


Script:

#!/bin/bash
# Locate all Rollup configuration files in the repository
fd --extension js --type f -e config.js -e rollup.config.js

Length of output: 769


Script:

#!/bin/bash
# Search for references to 'code-highlight' or CSS processing in Rollup configuration files
fd --extension js --type f -e config.js -e rollup.config.js | xargs rg --ignore-case "code-highlight|postcss|css"

Length of output: 853


Script:

#!/bin/bash
# Display the contents of packages/code-highlight/rollup.config.js
cat packages/code-highlight/rollup.config.js

Length of output: 551


Script:

#!/bin/bash
# Search for 'postcss' or 'cssnano' in packages/code-highlight/rollup.config.js
rg --ignore-case "postcss|cssnano" packages/code-highlight/rollup.config.js

Length of output: 77

Comment on lines +15 to +19

"import": "./dist/index.mjs",
"require": "./dist/index.js"
}
},
"./dist/css/style.css": "./dist/css/style.css"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

CSS export missing in packages/yjs/examples/frontend/package.json

The packages/yjs/examples/frontend/package.json does not include the "./dist/css/style.css": "./dist/css/style.css" export. To maintain consistency across the monorepo, please add this export to the exports section.

🔗 Analysis chain

Approve the addition of CSS export

The addition of "./dist/css/style.css": "./dist/css/style.css" to the exports section is a positive change. It allows users to directly import the CSS file, which is a good practice for modular CSS and aligns with the PR objective of fixing path resolve warnings.

Let's verify if this change is consistent across other modules in the monorepo:

This will help ensure consistency across the monorepo and identify if any other modules need similar updates.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if other package.json files in the monorepo have similar CSS exports

# Find all package.json files in the packages directory
fd package.json packages -x sh -c '
    if grep -q "\"./dist/css/style.css\": \"./dist/css/style.css\"" {}; then
        echo "CSS export found in {}"
    else
        echo "CSS export missing in {}"
    fi
'

Length of output: 813

packages/basic-modules/package.json Show resolved Hide resolved
"import": "./dist/index.mjs",
"require": "./dist/index.js"
}
},
"./dist/css/style.css": "./dist/css/style.css"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

CSS file not found at the specified location.

The packages/yjs-for-react/dist/css/style.css does not exist. Please ensure that the CSS file is correctly generated or update the export path in package.json accordingly.

🔗 Analysis chain

LGTM! Consider verifying the CSS file existence.

The addition of the CSS file export is a good practice for modular CSS management and aligns with the PR objective of fixing path resolve warnings. This change allows users to import the CSS file directly.

To ensure the CSS file exists at the specified location, you can run the following command:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the existence of the CSS file
if [ -f "packages/yjs-for-react/dist/css/style.css" ]; then
    echo "CSS file exists at the specified location."
else
    echo "Warning: CSS file not found at packages/yjs-for-react/dist/css/style.css"
fi

Length of output: 209


Script:

#!/bin/bash
# Search for any style.css files in the repository
fd "style\.css$" --exec ls -l {}

Length of output: 36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: 在 vite\vue3 项目中使用报错
1 participant