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

feat: move nuxt-legacy and nuxt-start into packages #3824

Merged
merged 38 commits into from
Aug 31, 2018
Merged

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Aug 30, 2018

This is a step towards Lerna style structure of Nuxt.js.

Branch

https://github.com/nuxt/nuxt.js/tree/refactor/packages/packages

Changes

  • Moved all stuff about nuxt-start into a package
  • Move nuxt-legacy into a new package
  • Core simplified
  • Package utility added
  • Common rollup config
  • Dynamic node builtins detection (@clarkdo)
  • New dist.js script. Package.json simplified

TODO

  • add Lerna
  • Fix edge release scripts
  • Use aliases as we don't plan to fully use Lerna for core until 3.x
  • Manual checks

@pi0 pi0 requested a review from clarkdo August 30, 2018 22:45
build/package.js Outdated
const { readFileSync, existsSync, readJSONSync, writeFileSync, copySync } = require('fs-extra')
const builtin = require('./builtin.json')

module.exports = class Package {
Copy link

Choose a reason for hiding this comment

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

I love how clean this is -- could we get this working with ESM syntax though?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. We can use node -r esm

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

files = source.packageObj.files || []
}

for (const file of files) {
Copy link

Choose a reason for hiding this comment

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

Widening parenthesis as blocks eliminates the need for extra variables -- since this style is already heavily employed throughout Nuxt, can we also do it for things like this?

    for (const file of files) {
      copySync(
        resolve(source.options.rootDir, file),
        resolve(this.options.rootDir, file)
      )
    }

Copy link
Member Author

Choose a reason for hiding this comment

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

I've kept variables for reasons:

  • No need to add extra comments. The code is much readable when using well-named variables
  • Adding complexities (Like more logics for resolving path with some if conditions) would require fewer changes to the code
  • Primarily I've separated variables soi can add some console logs about current operation without repeating code

Copy link

Choose a reason for hiding this comment

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

@pi0 yup, I do that too. And fair enough. Usually though when I realize there are no further references to something, I edit it into the call in the final revision. Perhaps we can selectively do that when it makes sense just before merging.


// Construct start package
const start = new Package({ rootDir: __dirname })

Copy link

Choose a reason for hiding this comment

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

Nice!

@galvez
Copy link

galvez commented Aug 31, 2018

Also @pi0 I've edited out [wip] and replaced with the WIP label :)

@galvez galvez changed the title [wip] move nuxt-legacy and nuxt-start into packages feat: move nuxt-legacy and nuxt-start into packages Aug 31, 2018
@galvez galvez added the WIP label Aug 31, 2018
@codecov-io
Copy link

codecov-io commented Aug 31, 2018

Codecov Report

Merging #3824 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #3824   +/-   ##
=======================================
  Coverage   97.84%   97.84%           
=======================================
  Files          18       18           
  Lines        1162     1162           
  Branches      317      317           
=======================================
  Hits         1137     1137           
  Misses         24       24           
  Partials        1        1

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 4311aca...a2b90b1. Read the comment docs.

@galvez
Copy link

galvez commented Aug 31, 2018

@pi0 have you tested if nuxt dev on a directory without node_modules still works? We should probably add a test for that.

@pi0
Copy link
Member Author

pi0 commented Aug 31, 2018

@galvez How is this related to this PR changes?

BTW as i remember it should be working fine

@galvez
Copy link

galvez commented Aug 31, 2018

@pi0 I'm not sure, just looked somewhat related. I'll take your word :)

@galvez
Copy link

galvez commented Aug 31, 2018

@pi0 argh, seems esm borked test/unit/module.test.js -- can you take a look? Don't sweat it if it's too much trouble, perhaps that flag isn't reliable for portability?

@pi0
Copy link
Member Author

pi0 commented Aug 31, 2018

@galvez No worries. It was an appveyor problem. Rebuilt fixed problem :)

.filter(x => !/^_|^(internal|v8|node-inspect)\/|\//.test(x) && !blacklist.includes(x))
.sort()

export const builtinsMap = () => builtins.reduce((obj, builtin) => {
Copy link
Member

Choose a reason for hiding this comment

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

Could we leverage Map here? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Actually I wrote it with Map at the beginning, but object is handy and also map structure underlying,so I changed.

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.

LGTM

@Atinux Atinux self-requested a review August 31, 2018 18:11
Copy link
Member

@Atinux Atinux left a comment

Choose a reason for hiding this comment

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

LGTM

@pi0 pi0 merged commit f854653 into dev Aug 31, 2018
@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

7 participants