-
Notifications
You must be signed in to change notification settings - Fork 309
fix(nuxt): fix the error when starting the nuxt project #2668
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
Conversation
WalkthroughThe pull request introduces significant updates to the project's configuration and build process, primarily focusing on the Changes
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 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 (
|
[e2e-test-warn] The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug". Please make sure you've read our contributing guide |
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: 4
🔭 Outside diff range comments (1)
packages/utils/src/crypt/core.ts (1)
Line range hint
328-339
: Define abstract methods for _doReset and _doFinalizeReplace the @ts-ignore comments with proper TypeScript abstract method declarations.
+ protected abstract _doReset(): void; + protected abstract _doFinalize(): WordArray;🧰 Tools
🪛 eslint
[error] 337-337: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.
(@typescript-eslint/ban-ts-comment)
[error] 337-337: Use "@ts-expect-error" to ensure an error is actually being suppressed.
(@typescript-eslint/prefer-ts-expect-error)
🧹 Nitpick comments (3)
examples/nuxt/playground/nuxt.config.ts (1)
11-11
: Consider making devtools configuration environment-specificWhile enabling devtools is helpful during development, it's recommended to make this configuration environment-aware to ensure it's not accidentally enabled in production.
Consider updating the configuration to be environment-specific:
- devtools: { enabled: true }, + devtools: { enabled: process.env.NODE_ENV === 'development' },packages/utils/tsconfig.json (1)
1-24
: Consider adding migration documentationThese TypeScript configuration changes represent a significant modernization that could affect existing code. Consider adding migration documentation to help developers understand and adapt to these changes.
Would you like me to help draft a migration guide that covers:
- Impact of ES2020 target
- New strict type checking requirements
- Vite integration details
packages/renderless/package.json (1)
Line range hint
1-46
: Review overall package architecture for Nuxt compatibilityThe changes across these packages suggest several potential causes for Nuxt startup issues:
- Module resolution might be affected by the new
.es.js
format- Different build tools (Vite vs tsup) might produce incompatible outputs
- The very recent Vite 6.0.0 might have compatibility issues
Consider:
- Documenting the minimum Nuxt version supported
- Adding a test case specifically for Nuxt integration
- Standardizing build tools and module formats across packages
- Creating a comprehensive build strategy document
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
examples/nuxt/playground/nuxt.config.ts
(1 hunks)examples/nuxt/playground/public/robots.txt
(0 hunks)package.json
(2 hunks)packages/mobile/utils/package.json
(1 hunks)packages/renderless/package.json
(1 hunks)packages/utils/package.json
(1 hunks)packages/utils/rollup.config.js
(0 hunks)packages/utils/src/crypt/core.ts
(4 hunks)packages/utils/tsconfig.json
(1 hunks)packages/utils/tsconfig.node.json
(1 hunks)packages/utils/vite.config.ts
(1 hunks)
💤 Files with no reviewable changes (2)
- examples/nuxt/playground/public/robots.txt
- packages/utils/rollup.config.js
✅ Files skipped from review due to trivial changes (2)
- packages/utils/vite.config.ts
- packages/utils/tsconfig.node.json
🧰 Additional context used
🪛 Biome (1.9.4)
packages/utils/src/crypt/core.ts
[error] 52-52: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.
(lint/complexity/noThisInStatic)
🪛 eslint
packages/utils/src/crypt/core.ts
[error] 49-49: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.
(@typescript-eslint/ban-ts-comment)
[error] 49-49: Use "@ts-expect-error" to ensure an error is actually being suppressed.
(@typescript-eslint/prefer-ts-expect-error)
[error] 51-51: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.
(@typescript-eslint/ban-ts-comment)
[error] 51-51: Use "@ts-expect-error" to ensure an error is actually being suppressed.
(@typescript-eslint/prefer-ts-expect-error)
[error] 56-56: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.
(@typescript-eslint/ban-ts-comment)
[error] 56-56: Use "@ts-expect-error" to ensure an error is actually being suppressed.
(@typescript-eslint/prefer-ts-expect-error)
[error] 283-283: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.
(@typescript-eslint/ban-ts-comment)
[error] 283-283: Use "@ts-expect-error" to ensure an error is actually being suppressed.
(@typescript-eslint/prefer-ts-expect-error)
[error] 328-328: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.
(@typescript-eslint/ban-ts-comment)
[error] 328-328: Use "@ts-expect-error" to ensure an error is actually being suppressed.
(@typescript-eslint/prefer-ts-expect-error)
[error] 337-337: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.
(@typescript-eslint/ban-ts-comment)
[error] 337-337: Use "@ts-expect-error" to ensure an error is actually being suppressed.
(@typescript-eslint/prefer-ts-expect-error)
🔇 Additional comments (11)
examples/nuxt/playground/nuxt.config.ts (1)
Line range hint 14-29
: Verify the impact of virtual template plugin configuration
The virtual template plugin is configured to include all index.ts files under packages/vue with a 'develop' environment setting. Please ensure this pattern correctly captures all necessary files and the environment setting is appropriate.
✅ Verification successful
Based on the output, I can now generate the final response as I have sufficient information to verify the virtual template plugin configuration.
Virtual template plugin configuration correctly captures necessary files
The pattern **/packages/vue/**/src/index.ts
effectively captures all the component entry points in the Vue package:
- All Vue components have their main entry point as
index.ts
files - The pattern matches both direct component entries (
packages/vue/src/[component]/index.ts
) and their implementations (packages/vue/src/[component]/src/index.ts
) - No critical template files are being missed, as other
.ts
files are primarily implementation details, types, utilities, and tests
The 'develop' environment setting is appropriate for this context as it's being used in a playground configuration.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the existence and pattern of files that would be processed by the virtual template plugin
# Check for matching files
echo "Files matching the virtual template plugin pattern:"
fd --type f "index.ts$" "packages/vue"
# Verify if any potential template files might be missed
echo -e "\nAll .ts files under packages/vue for comparison:"
fd --type f ".ts$" "packages/vue" | grep -v "index.ts"
Length of output: 29564
packages/utils/tsconfig.json (4)
23-24
: Verify the referenced tsconfig.node.json
The configuration references tsconfig.node.json
. This split configuration approach is good for separating concerns, but we need to ensure the referenced file exists and is properly configured.
Let's check the referenced configuration:
✅ Verification successful
Let me verify the specific tsconfig.node.json
that's being referenced from the utils package.
Split TypeScript configuration is properly set up
The referenced tsconfig.node.json
exists in the utils package and is correctly configured for Node.js/Vite specific settings. It includes:
- Proper module settings for ESNext and bundler
- Composite project configuration enabled
- Correct inclusion of
vite.config.ts
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the existence and content of tsconfig.node.json
fd -t f "tsconfig.node.json" -x cat {}
Length of output: 1722
Script:
#!/bin/bash
# Find the specific tsconfig.node.json in the utils package
fd -p "packages/utils/tsconfig.node.json" -x cat {}
Length of output: 266
9-15
: Verify Vite configuration alignment
The bundler mode settings are aligned with Vite requirements. However, ensure that the corresponding Vite configuration is properly set up.
Let's check for the Vite configuration:
✅ Verification successful
Bundler mode settings are correctly configured
The Vite configuration in packages/utils
is properly set up with library build mode and TypeScript support via vite-plugin-dts
. The tsconfig.json
bundler mode settings are correctly aligned with this Vite configuration, particularly for:
- Library builds with ES module format
- TypeScript declaration file generation
- Module resolution strategy
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify Vite configuration exists and is properly set up
fd -t f "vite.config"
Length of output: 535
Script:
#!/bin/bash
# Check the Vite configuration for packages/utils
cat packages/utils/vite.config.ts
Length of output: 333
3-8
: Verify browser compatibility requirements
The upgrade from ES5 to ES2020 and module changes to ESNext could impact browser compatibility. Ensure this aligns with your project's browser support requirements.
Let's check the browser targets configuration:
✅ Verification successful
Browser compatibility is well-supported with appropriate configuration
The upgrade to ES2020 is safe because:
- The project has browserslist configuration targeting "> 1%, last 2 versions"
- The build toolchain (Vite) handles transpilation and polyfills automatically
- Multiple configurations across the monorepo consistently use ES2020/ESNext targets
- The project uses modern module bundling with appropriate browser targeting
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check browser targets configuration
# Look for browserslist config or similar browser target specifications
fd -t f -e json package.json -x jq -r '.browserslist // .targets // empty'
fd -t f "browserslist|.browserslistrc"
Length of output: 202
Script:
#!/bin/bash
# Let's check if there are any explicit browser compatibility requirements in the documentation
rg -i "browser.*support|compatibility" README.md docs/ -l
# Check for any Vite configuration that might override TypeScript settings
fd -t f "vite.config" -x cat {}
# Check if there are any other TypeScript configurations that might be extending this one
fd -t f tsconfig.json -x cat {}
Length of output: 29184
17-21
: Verify impact of strict TypeScript checks
The addition of strict type checking and unused code checks is beneficial for code quality. However, these strict checks might reveal existing issues in the codebase.
Let's check for potential TypeScript errors:
packages/mobile/utils/package.json (1)
7-9
: Verify XSS package version consistency across packages
The addition of xss@1.0.14
while it's being removed from renderless package suggests a dependency reorganization. However, this could impact the Nuxt startup if not handled correctly.
Consider:
- Document why this dependency is needed specifically in mobile-utils
- Ensure proper tree-shaking since this is marked as
"sideEffects": false
✅ Verification successful
XSS package version is consistent and properly utilized
The verification shows:
- Version 1.0.14 is consistently used across packages (utils and mobile/utils)
- The package is actively used in mobile/utils for:
- HTML content filtering with configurable whitelists
- URL sanitization in upload functionality
- Attribute filtering
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for other xss package versions in the codebase
rg '"xss":' -g 'package.json'
# Check for direct xss usage in mobile utils
rg 'xss' packages/mobile/utils/
Length of output: 1900
packages/utils/package.json (2)
24-26
: Review dependency version constraints
The dependency versions raise some concerns:
- Vite v6.0.0 is extremely new and might be unstable
- TypeScript ^5.2.2 is quite recent and might need compatibility testing
Consider:
- Pinning Vite to a more stable version (e.g., ^5.0.0)
- Documenting the minimum required TypeScript version for Nuxt compatibility
11-12
: Verify module format compatibility with Nuxt
The change from esm.js
to es.js
and addition of types declaration needs verification with Nuxt's module resolution.
✅ Verification successful
Let me gather more information about the module format and build configuration to ensure compatibility.
Let me check the source files to understand the exports and usage patterns.
Based on the comprehensive analysis of the codebase, I can now provide the final response:
Module format is compatible with Nuxt and existing imports
The change from esm.js
to es.js
is safe because:
- The Vite build config explicitly sets
formats: ['es']
which is compatible with modern bundlers including Nuxt - All existing imports of
@opentiny/utils
are using named imports which work with ES modules - The package is only used by internal renderless components for utility functions like
xss
,log
, andcrypt
- TypeScript types are properly configured with
vite-plugin-dts
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for any imports of this package
rg '@opentiny/utils' -g '*.{js,ts,vue}'
Length of output: 2677
Script:
#!/bin/bash
# Check the build configuration and exports
cat packages/utils/vite.config.ts || cat packages/utils/vite.config.js
cat packages/utils/index.ts || cat packages/utils/index.js
Length of output: 505
Script:
#!/bin/bash
# Check the source files and exports
fd -t f . packages/utils/src/ -x cat {}
Length of output: 23532
packages/renderless/package.json (1)
Line range hint 31-33
: Consider build tool consistency across packages
While utils package moved to Vite, this package uses tsup. Having different build tools across packages might complicate the build process and potentially affect Nuxt startup.
Consider:
- Standardizing build tools across packages
- Document why different build tools are necessary if they must be maintained
Also applies to: 38-39
packages/utils/src/crypt/core.ts (1)
Line range hint 67-106
: LGTM! Robust type handling implementation
The WordArray class properly handles various array types and includes appropriate type conversions.
🧰 Tools
🪛 Biome (1.9.4)
[error] 52-52: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.
(lint/complexity/noThisInStatic)
🪛 eslint
[error] 49-49: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.
(@typescript-eslint/ban-ts-comment)
[error] 49-49: Use "@ts-expect-error" to ensure an error is actually being suppressed.
(@typescript-eslint/prefer-ts-expect-error)
[error] 51-51: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.
(@typescript-eslint/ban-ts-comment)
[error] 51-51: Use "@ts-expect-error" to ensure an error is actually being suppressed.
(@typescript-eslint/prefer-ts-expect-error)
[error] 56-56: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.
(@typescript-eslint/ban-ts-comment)
[error] 56-56: Use "@ts-expect-error" to ensure an error is actually being suppressed.
(@typescript-eslint/prefer-ts-expect-error)
package.json (1)
35-35
: LGTM! Verify build order dependencies
The addition of pnpm build:utils
to postinstall script is appropriate. However, ensure that build:internals
doesn't depend on the utils package to avoid circular dependencies.
✅ Verification successful
Based on the gathered information, I can now generate the final response:
LGTM! No circular dependencies found
The build order in postinstall script is correct. The utils package has minimal dependencies (only xss) and none of the internal packages depend on @opentiny/utils, confirming there are no circular dependencies between internals and utils.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for potential circular dependencies between internals and utils
rg -l "require.*@opentiny/utils|from.*@opentiny/utils" "internals/"
Length of output: 67
Script:
#!/bin/bash
# Let's first check if the internals directory exists and its structure
fd . internals/
# Then check for any imports or requires in the internals directory
rg -g '!*.{json,md}' "import|require" internals/
# Also check the build scripts in package.json to understand the build order
cat package.json | jq '.scripts'
Length of output: 56844
Script:
#!/bin/bash
# Let's check the build:internals and build:utils scripts' dependencies
cat packages/utils/package.json | jq '.dependencies'
# Also check if utils is used in any of the internals packages
fd package.json internals/ -x cat {} | jq -c 'select(.dependencies != null) | {name: .name, dependencies: .dependencies}'
Length of output: 1359
"build": "rimraf dist && npm run build:dev && npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:prod", | ||
"release": "node scripts/release.js", | ||
"lint": "eslint src/**/*{.js,.ts,.json} --fix", | ||
"build": "vite build", |
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.
Consider using a more stable Vite version
The switch to Vite build system is good for modern development, but using vite build
alone might need additional configuration for Nuxt compatibility.
Consider:
- Adding Nuxt-specific build configuration
- Using a more stable Vite version (6.0.0 is very recent and might have stability issues)
// @ts-ignore | ||
static create(...args) { | ||
// @ts-ignore | ||
return new this(...args) | ||
} |
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.
Replace @ts-ignore with proper type definitions
The @ts-ignore
comments should be replaced with proper TypeScript type definitions. Additionally, using this
in a static context could be confusing.
Consider this implementation:
- // @ts-ignore
- static create(...args) {
- // @ts-ignore
- return new this(...args)
+ static create<T extends new (...args: any[]) => any>(...args: ConstructorParameters<T>): InstanceType<T> {
+ return new (this as any)(...args)
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// @ts-ignore | |
static create(...args) { | |
// @ts-ignore | |
return new this(...args) | |
} | |
static create<T extends new (...args: any[]) => any>(...args: ConstructorParameters<T>): InstanceType<T> { | |
return new (this as any)(...args) | |
} |
🧰 Tools
🪛 Biome (1.9.4)
[error] 52-52: Using this in a static context can be confusing.
this refers to the class.
Unsafe fix: Use the class name instead.
(lint/complexity/noThisInStatic)
🪛 eslint
[error] 49-49: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.
(@typescript-eslint/ban-ts-comment)
[error] 49-49: Use "@ts-expect-error" to ensure an error is actually being suppressed.
(@typescript-eslint/prefer-ts-expect-error)
[error] 51-51: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.
(@typescript-eslint/ban-ts-comment)
[error] 51-51: Use "@ts-expect-error" to ensure an error is actually being suppressed.
(@typescript-eslint/prefer-ts-expect-error)
@@ -277,6 +280,7 @@ | |||
|
|||
if (mWordsReady) { | |||
for (let offset = 0; offset < mWordsReady; offset += blockSize) { | |||
// @ts-ignore |
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.
🛠️ Refactor suggestion
Define abstract method instead of using @ts-ignore
Replace the @ts-ignore with proper TypeScript abstract method declaration.
+ protected abstract _doProcessBlock(dataWords: any[], offset: number): void;
Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 eslint
[error] 283-283: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.
(@typescript-eslint/ban-ts-comment)
[error] 283-283: Use "@ts-expect-error" to ensure an error is actually being suppressed.
(@typescript-eslint/prefer-ts-expect-error)
// @ts-ignore | ||
const clone = new this.constructor() | ||
Object.assign(clone, this) | ||
return clone |
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.
🛠️ Refactor suggestion
Implement proper deep cloning
The current implementation using Object.assign
performs a shallow clone, which might not correctly handle nested objects or arrays.
Consider using a deep clone implementation:
- // @ts-ignore
- const clone = new this.constructor()
- Object.assign(clone, this)
- return clone
+ const clone = new (this.constructor as new () => typeof this)()
+ for (const key in this) {
+ if (Object.prototype.hasOwnProperty.call(this, key)) {
+ if (this[key] && typeof this[key] === 'object') {
+ clone[key] = Array.isArray(this[key])
+ ? [...this[key]]
+ : { ...this[key] }
+ } else {
+ clone[key] = this[key]
+ }
+ }
+ }
+ return clone
Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 eslint
[error] 56-56: Include a description after the "@ts-ignore" directive to explain why the @ts-ignore is necessary. The description must be 3 characters or longer.
(@typescript-eslint/ban-ts-comment)
[error] 56-56: Use "@ts-expect-error" to ensure an error is actually being suppressed.
(@typescript-eslint/prefer-ts-expect-error)
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores