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

[BREAKING CHANGE] Replace constructor function to class declaration #30

Merged
merged 4 commits into from Jul 25, 2019

Conversation

@segayuu
Copy link
Contributor

commented Oct 8, 2018

No description provided.

@segayuu segayuu requested a review from hexojs/core Oct 8, 2018
@segayuu segayuu force-pushed the segayuu:replace-class branch from d3ca5f8 to fef5ecf Oct 8, 2018
Copy link
Contributor

left a comment

@segayuu

In the future please provide:

  • a description and reasoning
  • how to test

We should also include something like this in a PR template across the repos where there is time.

For example:

It changes all the modules to use ES6 class-syntax instead of mimicking classes using prototypal inheritance. The reason we can do this without babel is because we're targeting >=node@6.0.0 in ./package.json.

How to test:

git clone -b replace-class https://github.com/segayuu/warehouse.git
cd warehouse
npm install
npm test
@tcrowe

This comment has been minimized.

Copy link
Contributor

commented Oct 8, 2018

I found a problem integrating it with https://github.com/hexojs/hexo.

git clone -b replace-class https://github.com/segayuu/warehouse.git
cd warehouse
npm install
cd ..
git clone https://github.com/hexojs/hexo.git
cd hexo
npm install
npm rm warehouse
npm install ../warehouse
npm test

The result is this error:

TypeError: Class constructor SchemaType cannot be invoked without 'new'
    at new SchemaTypeMoment (hexo/lib/models/types/moment.js:8:14)
    at getSchemaType (warehouse/lib/schema.js:90:10)
    at Schema.path (warehouse/lib/schema.js:118:18)
    at Schema.add (warehouse/lib/schema.js:78:10)
    at new Schema (warehouse/lib/schema.js:56:12)
    at Object.module.exports.ctx [as Page] (hexo/lib/models/page.js:9:16)

@segayuu Maybe you can advise me here. Unless I did something wrong we may need to adjust other modules for compatibility.

@segayuu

This comment has been minimized.

Copy link
Contributor Author

commented Oct 9, 2018

I appreciate @tcrowe 's review!

This error message is not a bug.
The constructor generated by class declaration or class expression can not use SuperClass.call() equivalent to super().
For this reason, if the base class is defined with a class declaration or the like, derived classes will not be able to inherit classes in ES5 style.
Due to that influence, the number of change files of this PR has become very large.

Either way, the SchemaType class and its derived classes are assumed to inherit from the outside.
If emphasis is placed on compatibility, that class group will not be able to switch to the class declaration.

@YoshinoriN

This comment has been minimized.

Copy link
Member

commented Oct 9, 2018

@tcrowe @segayuu

I think, following procedure is better way for migrate warehouse repository to class declaration.

  • Migrate this ripository sorce code to class declaration (this PR)
  • Warehouse package's versionup (major verup) and publish to npm
    • Also announce or write readme about breaking change.
  • Update hexo main repo's warehouse package version and fix related code.

I think hexo's core repositories should to be migrate ES6 step by step.

@segayuu

This comment has been minimized.

Copy link
Contributor Author

commented Oct 19, 2018

Ten days have passed since the last comment, and there are reactions with pictograms, so I will change the README.md and request a review again.

@segayuu segayuu changed the title Replace constructor function to class declaration [BREAKING CHANGE] Replace constructor function to class declaration Oct 19, 2018
 - Writing a text page assuming that major version upgrade was done.
@segayuu segayuu requested a review from hexojs/core Oct 19, 2018
segayuu added 2 commits Jun 13, 2019
@tcrowe
tcrowe approved these changes Jun 24, 2019
Copy link
Contributor

left a comment

I tested it and it works well. Thank you, @segayuu @YoshinoriN 👍

@YoshinoriN YoshinoriN added this to the v3.0.0 milestone Jun 25, 2019
@segayuu segayuu merged commit 34399c5 into hexojs:master Jul 25, 2019
1 of 2 checks passed
1 of 2 checks passed
coverage/coveralls Coverage decreased (-0.1%) to 95.55%
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@segayuu segayuu deleted the segayuu:replace-class branch Jul 25, 2019
segayuu added a commit to segayuu/warehouse that referenced this pull request Jul 25, 2019
segayuu added a commit that referenced this pull request Sep 7, 2019
* Revert "[BREAKING CHANGE] Replace constructor function to class declaration (#30)"

This reverts commit 34399c5.

* Run lebab

* Restore README.md before revert

* Perform class conversion not handled by lebab

* Remove unnecessary differences with master branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.