-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Examples: Deprecate examples/js. #18749
Conversation
I've written this script to perform the addition of the console log in the js files: const fs = require( 'fs' );
const path = require( 'path' );
const srcFolder = __dirname + '/../examples/js';
const excludedDirectories = [ 'libs', 'vr' ];
function walk( dir ) {
let results = [];
const list = fs.readdirSync( dir );
list.forEach( function ( file ) {
if ( excludedDirectories.includes( file ) === true ) return [];
file = dir + '/' + file;
const stat = fs.statSync( file );
if ( stat && stat.isDirectory() ) {
results = results.concat( walk( file ) );
} else {
results.push( file );
}
} );
return results;
}
const files = walk( srcFolder );
for ( let file of files ) {
const data = fs.readFileSync( file );
const fd = fs.openSync( file, 'w+' );
const filename = path.parse( file ).name;
const buffer = Buffer.from( `console.warn( "THREE.${filename}: Importing from 'examples/js' is now deprecated. Please import ES6 modules from 'examples/jsm' instead. Refer to the announcement and documentation, or reach out on the forums if you need guidance with this change. Announcement: TODO. Documentation: https://threejs.org/docs/index.html#manual/en/introduction/Import-via-modules." );\n`, 'utf8' );
fs.writeSync( fd, buffer, 0, buffer.length, 0 );
fs.writeSync( fd, data, 0, data.length, buffer.length );
fs.closeSync( fd );
} It's no part of the PR hence I share the code here. |
Maybe refer to it as "release r117"
so as to follow the three.js nomenclature: https://github.com/mrdoob/three.js/releases/tag/r113. |
This is going to break a lot of SO answers. That is fine with me, but I am trying to maintain 1300+ of my SO answers, and like others, there will be a lot of fiddles that will no longer work. I do not want to modularize each of those fiddles, so I guess I will have to delete them. Since this will also impact others who have provided answers or blog posts online, perhaps there are suggestions on how to proceed in this regard... I do not think it is a good idea to link to outdated, static revisions of the library in SO answers. |
I would suggest softening the warning a bit. It will be the first that many users have heard of the deprecation, and this will be the most significant breaking change our API has had in a while. I agree that there's good reason for it, but even for experienced developers, upgrading an application's build process to support ES6 does take a bit of time. I'm not sure that I would include a deadline in the first release — we'll probably get a few "I can't/won't upgrade because ________" responses, and it'd be good to work through the most common issues before we start getting the more heated responses that could accompany a deadline.
I also expect we'll need to provide more documentation than is currently available on the Import via modules page. Do we expect this warning would go out in r115? I can probably help write that, but would need to know the planned timing. |
@donmccurdy I've updated the warning with your suggestion. To avoid complexity, it would be good if the warning is a one liner. This makes it easier to remove it in I would appreciate if you could write the announcement in the forum and enhance the Import via modules page a bit. Such things are not really my strength. @WestLangley Yes, it's unfortunate when live examples break, however, it's also our own fault. Instead of using links like
which will obviously not working anymore after the removal, we should have used links like:
Of course CDN can also shut down but using a locked version is definitely better than always targeting the latest version. |
I disagree with that, which is why I did not do it that way. As I said, that means the SO fiddles will continue to work, but maybe not with the current release -- and that is not particularly helpful to users. In any event, removing |
Sorry to bikeshed, if this is a pain then please ignore my suggestion. But I think it could be done with something like: console.warn( THREE.LEGACY_IMPORT.replace('{filename}', 'GLTFLoader') ); |
Sure. Targeting r115 (for the announcement), I assume? |
It's totally understandable that you don't want to update all of these to modules. However, it would be a real shame to lose this huge bank of learning resources. What if we reach out and ask for help updating them on the forum and on Twitter? Do you have a list of all the examples somewhere? If so I'll make a post on the forum and see if there's any interest in doing this. |
@mrdoob is this okay for you? |
Hi everyone, I have an opinion about this problem as followings: I think you guys shouldn't deprecate 'examples/js', because: |
@hdtung88 TBH, I can't follow your argumentation. If you really end up with a bigger file size, you seem to do something wrong in your build. I suggest you post this problem at stackoverflow. |
There is nothing wrong with my build. |
Can you make a post on the forum? We can discuss your problem there. Please include a code sample that demonstrates the problem so that other people can test it, if possible. If it turns out this is actually impossible to solve without using |
This process seems to be stalled. Is there a next step that I or others could help with? |
Sorry for the delay. I think this PR is good. Just a few conflicts to fix. Regarding the message...
How about something like this?
|
How about including |
Um, but this approach won't automatically log warnings when users import files from the |
@mrdoob I've solved the conflicts and added the new text. |
Thanks! |
Uh oh... in fact it appears to be worse than that... |
I think this PR included a change to |
/cc #19473 |
Yes, sorry. The last force-push has overwritten this change. |
@donmccurdy We discussed a bit earlier that it might be a good idea to explain users the reasons of this PR a bit. Especially since the removal of |
Yes, agreed. I will write something up. |
@Mugen87 I just ran into this deprecation message for the first time and was a bit confused because it says
but it doesn't give you an alternative solution. You have to copy-paste the URL and scroll to "Importable Examples" at the bottom of that page before the user can learn what to do. Wouldn't it be more user-friendly if the suggested course-of-action was part of the warning itself?
|
@marquizzo I'll write up a more detailed post about this and put it in the forum (see above). Perhaps we should link there from the deprecation message, once it's up. |
Right, I understand there'll be a more formal post explaining why in the near future. But shouldn't the warning also say "please import via modules from 'examples/jsm'"? I feel that all Three.js warnings give you the solution as part of the warning itself, but this one makes you look for the solution elsewhere. Anyway, just my suggestion 🙂. |
I think that's what the deprecation warning is trying to say, yes, but maybe it could be clearer. As convenient as it is to have detailed explanations in error messages, large strings of text don't minify well, so that's a tradeoff. This example probably matters less because the messages are (a) not in the core library, and (b) all the same so Gzip may help more. |
Opened #19622. |
This resolves a deprecation warning, introduced in three.js in May: mrdoob/three.js#18749
This resolves a deprecation warning, introduced in three.js in May: mrdoob/three.js#18749
This PR will deprecate all files in the
examples/js
directory except for all external libraries. A console message will warn the user about the removal of those files in one of the upcoming releases. Right now, I've addedR117
. The exact date is of course open for discussion. Same for the warning's text.The PR replaces #17544.