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

module: remove unnecessary property and method #2922

Closed
wants to merge 1 commit into from

Conversation

thefourtheye
Copy link
Contributor

require.paths property and require.registerExtension function have
been throwing errors when used. They both are like this for years now.
This patch removes them from the system.

require.paths: 7f0047c#diff-d1234a869b3d648ebfcdce5a76747d71R359

require.registerExtension was removed even before that.

`require.path` property and `require.registerExtension` function have
been throwing errors when used. They both are like this for years now.
This patch removes them from the system.
@thefourtheye thefourtheye added the module Issues and PRs related to the module subsystem. label Sep 16, 2015
@mscdex mscdex added the semver-major PRs that contain breaking changes and should be released in the next major version. label Sep 17, 2015
@thefourtheye
Copy link
Contributor Author

@thefourtheye
Copy link
Contributor Author

Bump!

@silverwind
Copy link
Contributor

LGTM

@thefourtheye
Copy link
Contributor Author

I'll land this tomorrow if there are no objections. cc @nodejs/collaborators

@indutny
Copy link
Member

indutny commented Sep 28, 2015

cc @rvagg what does our deprecation policy says on this?

@mscdex
Copy link
Contributor

mscdex commented Sep 28, 2015

LGTM

@seishun
Copy link
Contributor

seishun commented Sep 28, 2015

Why semver-major though? It was already removed. It's not like any application will break because of this change.

@thefourtheye
Copy link
Contributor Author

@seishun True, if anyone is using it then their application will just fail. @mscdex What do you think?

@ChALkeR
Copy link
Member

ChALkeR commented Sep 28, 2015

@thefourtheye It was require.paths, not require.path.

@@ -127,10 +127,6 @@ assert.equal(require('../fixtures/registerExt2').custom, 'passed');
assert.equal(require('../fixtures/foo').foo, 'ok',
'require module with no extension');

assert.throws(function() {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Can you add a test to confirm that require.paths returns undefined or whatever the expected value is?

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Probably good to do the same for require.registerExtension().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Trott Do we really need that? There will be no reference to that in code, but there will be a test which will check if paths is undefined.

Copy link
Member

Choose a reason for hiding this comment

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

My thinking is this PR changes the behavior of the code and there ought to be a test for that change. So a test that the property has, in fact, been successfully removed seems appropriate. But if you think it's overkill, I'm OK without it. (I'll edit my comments above to indicate they are nits.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Trott Hmmm, whenever we remove something from the system we don't add tests to make sure that they are really removed, right? So, I feel that it is not necessary. Let's see what others feel.

@thefourtheye
Copy link
Contributor Author

@ChALkeR Ah, thanks for pointing out. I edited the PR description. I'll update the commit log when I am landing this.

@ChALkeR
Copy link
Member

ChALkeR commented Sep 28, 2015

@seishun It changes the behavior by removing a throw. If anyone did a feature detection checking whenether require.paths throws or not, it would be broken by this commit. While the likehood of such situation is near zero, it still makes this PR a semver-major IMO.

@ChALkeR
Copy link
Member

ChALkeR commented Sep 28, 2015

require.registerExtension( usage:

amdify-0.0.26.tgz/jam/ejs/lib/ejs.js:350:  require.registerExtension('.ejs', function(src) {
backbone-revisited-0.1.2.tgz/node_mods/ejs.js:353:  require.registerExtension('.ejs', function(src) {
blitzLib-0.1.0.tgz/Lib/coffee-script-debug.js:14330:    }: require.registerExtension && require.registerExtension(".coffee",
bluebutton-0.4.2.tgz/_site/spec/javascripts/helpers/ejs.js:411:  require.registerExtension('.ejs', function(src) {
clientexpress-0.7.7.tgz/lib/ejs.js:301:  require.registerExtension('.ejs', function(src) {
coffeete-0.0.4.tgz/src/coffeete.js:22:        require.registerExtension('.coffeete', function (content) {
contracts.coffee-0.3.4.tgz/lib/coffee-script/coffee-script.js:24:    require.registerExtension('.coffee', function(content) {
ejs-harmony-1.0.1.tgz/lib/ejs.js:413:  require.registerExtension('.ejs', function(src) {
ejs-i-1.2.3.tgz/ejs.js:417:      require.registerExtension('.ejs', function (src) {
ejs-i-1.2.3.tgz/lib/ejs.js:399:  require.registerExtension('.ejs', function (src) {
ejs-remix-0.1.1.tgz/ejs.js:346:  require.registerExtension('.ejs', function(src) {
ejs-remix-0.1.1.tgz/lib/ejs.js:504:  require.registerExtension('.ejs', function(src) {
ejs-template-0.1.0.tgz/ejs/ejs.js:376:  require.registerExtension('.ejs', function(src) {
ejs-var-1.0.0.tgz/ejs.js:411:  require.registerExtension('.ejs', function(src) {
ejs-var-1.0.0.tgz/lib/ejs.js:374:  require.registerExtension('.ejs', function(src) {
ender-ejs-0.6.1.tgz/ejs.js:334:  require.registerExtension('.ejs', function(src) {
funtang.compiler-0.0.1.tgz/reference/jashkenas-coffee-script-60c9b94/lib/coffee-script/coffee-script.js:25:    require.registerExtension('.coffee', function(content) {
gorillascript-0.9.10.tgz/extras/gorillascript.js:30580:          require.registerExtension(".gs", function (content) {
gorillascript-0.9.10.tgz/lib/gorilla.js:435:    require.registerExtension(".gs", function (content) {
imba-0.13.0.tgz/register.js:39: require.registerExtension('.imba',function (content){
logmonger-0.1.0.tgz/contrib/coffee-script/coffee-script.js:14:    require.registerExtension('.coffee', function(content) {
mochiscript-0.6.16.tgz/lib/mochiscript/mochiscript.js:1280:  require.registerExtension('.ms', function(content, filename) {
neode-0.0.0.tgz/coffee-script/lib/coffee-script/coffee-script.js:25:    require.registerExtension('.coffee', function(content) {
ngine-0.0.2.tgz/lib/ejs.js:387:  require.registerExtension('.ejs', function(src) {
periodic.component.list-view-scroll-0.1.1.tgz/example/scripts/example.js:2827:  require.registerExtension('.ejs', function(src) {
sdejs-0.0.2.tgz/lib/sdejs.js:376:  require.registerExtension('.ejs', function(src) {
sdejs-0.0.2.tgz/sdejs.js:420:  require.registerExtension('.ejs', function(src) {
springbokejs-0.0.1.tgz/ejs.js:346:  require.registerExtension('.ejs', function(src) {
springbokejs-0.0.1.tgz/lib/ejs.js:378:  require.registerExtension('.ejs', function(src) {
tinyliquid-0.2.29.tgz/other/ejs.js:411:  require.registerExtension('.ejs', function(src) {
toffee-0.1.12.tgz/lib/coffee-script/coffee-script.js:25:    require.registerExtension('.coffee', function(content) {
TwigJS-0.0.2.tgz/support/coffee-script/lib/coffee-script/coffee-script.js:17:    require.registerExtension('.coffee', function(content) {
twigjs-0.0.4.tgz/support/coffee-script/lib/coffee-script/coffee-script.js:17:    require.registerExtension('.coffee', function(content) {
utml-0.2.0.tgz/utml.js:224:  require.registerExtension('.utml', function(src){
vork-0.0.12.tgz/exampleApp/app/requirejsBuilder/plugins/ejs.js:333:                require.registerExtension('.ejs', function(src) {
wsi-ejs-1.2.0.tgz/ejs.js:413:  require.registerExtension('.ejs', function(src) {
wsi-ejs-1.2.0.tgz/lib/ejs.js:361:  require.registerExtension('.ejs', function(src) {
yerbascript-0.0.1.tgz/lib/coffee-script/coffee-script.js:31:    require.registerExtension('.yerba', function(content) {
yerbascript-0.0.1.tgz/lib/coffee-script/coffee-script.js:34:    require.registerExtension('.coffee', function(content) {

Most of them do an } else if (require.registerExtension) { check before calling require.registerExtension.

@mscdex
Copy link
Contributor

mscdex commented Sep 28, 2015

IMHO I would just remove them both, they have been deprecated for a long time now, at least since 2011. It's not like it was a soft deprecation either.

@ChALkeR
Copy link
Member

ChALkeR commented Sep 28, 2015

@thefourtheye
Copy link
Contributor Author

@ChALkeR Are all those packages latest?

@ChALkeR
Copy link
Member

ChALkeR commented Sep 28, 2015

@thefourtheye For 2015-09-21, yes.

@thefourtheye
Copy link
Contributor Author

hmmm, I wonder how they are really working.

@ChALkeR
Copy link
Member

ChALkeR commented Sep 28, 2015

There could be a lot of false positives for require.paths — the code could be performing feature detection to be compatible with old versions, «require» and «paths» are common words, so it might be a different «require», some lines are actually comments or strings.

Also some modules are not used by anybody.

@ChALkeR
Copy link
Member

ChALkeR commented Sep 28, 2015

@thefourtheye Also note that those are only 1100 lines in 442 modules for require.paths. From 186231 modules on npm. That's actually 0.2%. Together with the false positives.

@rvagg
Copy link
Member

rvagg commented Sep 29, 2015

cc @rvagg what does our deprecation policy says on this?

Not sure we have coverage of this kind of situation because it's not even deprecated, it's flat-out broken. I could imagine a situation where you're using the exception in some upstream workflow but you'd have to be more than a little crazy to be doing that I think..

I bet lot of those packages are either not attempting to use that functionality (notice how many have ejs.js or coffee-script.js in a lib directory?) or are simply abandonware.

I'm +0.5 on this as long as it's only for v5+.

@thefourtheye
Copy link
Contributor Author

@ChALkeR LGTY?

@ChALkeR
Copy link
Member

ChALkeR commented Oct 4, 2015

@thefourtheye
LGTM for a major.

Also, most of those require.paths usage lines are throwing an error without this PR (in 4.x) and will throw an error (though a different one) with this PR (in 5.x), as they attempt to do require.paths.something(…), for example require.paths.unshift(…).

@Fishrock123
Copy link
Contributor

LGTM for v5

@Fishrock123 Fishrock123 added this to the 5.0.0 milestone Oct 5, 2015
@bnoordhuis
Copy link
Member

LGTM

thefourtheye added a commit that referenced this pull request Oct 6, 2015
`require.paths` property and `require.registerExtension` function have
been throwing errors when used. They both are like this for years now.
This patch removes them from the system.

PR-URL: #2922
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module Issues and PRs related to the module subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants