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

Display proper error when specified plugin isn't found #3672

Merged
merged 6 commits into from Aug 10, 2018
Merged

Display proper error when specified plugin isn't found #3672

merged 6 commits into from Aug 10, 2018

Conversation

galvez
Copy link

@galvez galvez commented Aug 10, 2018

Picking up on #3434 -- synced with dev and tests included.

@codecov-io
Copy link

codecov-io commented Aug 10, 2018

Codecov Report

Merging #3672 into dev will decrease coverage by 0.08%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #3672      +/-   ##
==========================================
- Coverage   98.94%   98.86%   -0.09%     
==========================================
  Files          18       18              
  Lines        1134     1142       +8     
  Branches      304      307       +3     
==========================================
+ Hits         1122     1129       +7     
- Misses         12       13       +1
Impacted Files Coverage Δ
lib/builder/builder.js 97.92% <66.66%> (-0.46%) ⬇️
lib/builder/webpack/base.js 100% <0%> (ø) ⬆️
lib/builder/webpack/server.js 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c7701d...cd3e707. Read the comment docs.

@manniL manniL requested review from clarkdo and Atinux August 10, 2018 05:52
@manniL
Copy link
Member

manniL commented Aug 10, 2018

Have you looked into the comment from pi0 in #3434? 🤔

Shouldn't we first resolve plugin's full path? Something like ~/plugins/my_plugin.js would throw an error. right?

@galvez
Copy link
Author

galvez commented Aug 10, 2018 via email

Copy link
Member

@clarkdo clarkdo left a comment

Choose a reason for hiding this comment

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

Where is better to add this check ?

  1. https://github.com/nuxt/nuxt.js/blob/cb18aa6f534137f4a8c462404e9b39850a13391f/lib/builder/builder.js#L65
  2. Inside a same loop like previous pr
  3. Current pr

@@ -43,4 +43,16 @@ describe('nuxt', () => {

await nuxt.close()
})

test('Fail to build when specified plugin isn\'t found', () => {
const nuxt = new Nuxt({
Copy link
Member

Choose a reason for hiding this comment

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

Run a complete build here seems too expensive

Copy link
Author

Choose a reason for hiding this comment

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

@clarkdo Not so much because it very quickly fails and exits.

@galvez
Copy link
Author

galvez commented Aug 10, 2018

@clarkdo good call re: plugins() -- I'll adapt.

if (!exists) {
consola.warn(`Plugin not found: ${plugin.src}`)
}
return exists
Copy link
Member

Choose a reason for hiding this comment

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

Can’t return Boolean here, need plugin

@galvez
Copy link
Author

galvez commented Aug 10, 2018 via email

@galvez
Copy link
Author

galvez commented Aug 10, 2018

@clarkdo I changed my approach entirely now. Can you read the PR again?

}).map((p) => ({
src: this.nuxt.resolveAlias(p.src),
ssr: p.ssr !== false,
name: 'nuxt_plugin_' + p.basename + '_' + hash(p.src)
Copy link
Member

Choose a reason for hiding this comment

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

Any reason for moving base name calculation above?

Copy link
Author

Choose a reason for hiding this comment

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

@clarkdo so we don't do it twice. I need that same calculation to display any potential warnings in the preceding filter().

}).filter((p) => {
exists = fs.existsSync(this.nuxt.resolveAlias(p.src))
if (!exists) {
consola.warn(`Plugin not found: ${p.basename}`)
Copy link
Member

Choose a reason for hiding this comment

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

I think you can use reduce instead of filter+map.
And I didn’t see any pleace else in this method is using basename, so it should be unnecessary to extract it calculation

}
const basename = path.basename(p.src, path.extname(p.src))
.replace(/[^a-zA-Z?\d\s:]/g, '')
return [ ...arr, {
Copy link
Member

Choose a reason for hiding this comment

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

Here everytime will create a new array, how about:

arr.push({
  src: pluginPath,
  ssr: p.ssr !== false,
  name: 'nuxt_plugin_' + basename + '_' + hash(p.src)
})
return arr

}
const basename = path.basename(p.src, path.extname(p.src))
.replace(/[^a-zA-Z?\d\s:]/g, '')
return [...arr, {
Copy link
Member

Choose a reason for hiding this comment

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

Here everytime will create a new array, how about:

arr.push({
  src: pluginPath,
  ssr: p.ssr !== false,
  name: 'nuxt_plugin_' + basename + '_' + hash(p.src)
})
return arr

@lock
Copy link

lock bot commented Oct 31, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 31, 2018
@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants