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: Duplicate declaration plugin when add/remove file in dev mode #4278

Merged
merged 1 commit into from
Nov 6, 2018

Conversation

clarkdo
Copy link
Member

@clarkdo clarkdo commented Nov 6, 2018

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Probably resolve #4275

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

@codecov-io
Copy link

Codecov Report

Merging #4278 into dev will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #4278      +/-   ##
==========================================
+ Coverage   92.28%   92.29%   +<.01%     
==========================================
  Files          52       52              
  Lines        1712     1713       +1     
  Branches      447      447              
==========================================
+ Hits         1580     1581       +1     
  Misses        126      126              
  Partials        6        6
Impacted Files Coverage Δ
packages/builder/src/builder.js 95.39% <100%> (+0.03%) ⬆️

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 1a154e8...379623e. Read the comment docs.

@clarkdo clarkdo merged commit 3f2b10e into nuxt:dev Nov 6, 2018
@@ -207,6 +207,7 @@ export default class Builder {
async generateRoutesAndFiles() {
consola.debug(`Generating nuxt files`)

this.plugins.length = 0
this.plugins.push.apply(this.plugins, this.normalizePlugins())
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 we still simply set a new array to this.plugins?

Copy link
Member

Choose a reason for hiding this comment

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

This wouldn't clear all references of this.plugins

Copy link
Member Author

Choose a reason for hiding this comment

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

BuildContext is using it for registering alias in webpack builder.

Copy link
Member Author

@clarkdo clarkdo Nov 6, 2018

Choose a reason for hiding this comment

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

I have an idea, will open a pr.
@pi0 How do you think:

  get plugins() {
    return this._plugins
  }

  set plugins(plugins) {
    this._plugins = plugins
    if (this.bundleBuilder) {
      this.bundleBuilder.context.plugins = plugins
    }
  }

Copy link
Member

Choose a reason for hiding this comment

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

I love the getter idea. But suggest moving getters into BuildContext class. An smart context with always updated computed props. Allows us changing it's logic anytime without adding complexities to neither Builder or Wevpack

@lock
Copy link

lock bot commented Dec 6, 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 Dec 6, 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.

Code duplication on hot reload
6 participants