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

Use the latest punycode(1.3.2) #1865

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

oldmtn
Copy link

@oldmtn oldmtn commented Aug 31, 2018

Use the latest punycode, since punycode(1.3.2) export with:
define('punycode', function() { return punycode; });
which isn't portable when using requireJS.

define('punycode', function() {
    return punycode;
});
which is portable when using requireJS.
Copy link
Member

@goto-bus-stop goto-bus-stop left a comment

Choose a reason for hiding this comment

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

Node.js uses punycode 2.0.0 and it'd be best if we're in sync with them.

However punycode 2+ use ES6 features which are only supported in recent browsers, ideally browserify's node core shims work way back in old browsers too…

punycode 2.0.0 is actually identical to 1.3.2 except for the ES6 syntax. The best thing to do here might be to have a new punycode-browserify package that is punycode 2.0.0 compiled to ES5.

@oldmtn
Copy link
Author

oldmtn commented Aug 31, 2018

punycode 2.0.0 is actually identical to 1.3.2 except for the ES6 syntax.

I don't think so.
// punycode, 1.3.2

define('punycode', function() {
    return punycode;
});

// punycode, 2.0.0

/** Define the public API */
const punycode = {
	/**
	 * A string representing the current Punycode.js version number.
	 * @memberOf punycode
	 * @type String
	 */
	'version': '2.0.0',
	/**
	 * An object of methods to convert from JavaScript's internal character
	 * representation (UCS-2) to Unicode code points, and back.
	 * @see <https://mathiasbynens.be/notes/javascript-encoding>
	 * @memberOf punycode
	 * @type Object
	 */
	'ucs2': {
		'decode': ucs2decode,
		'encode': ucs2encode
	},
	'decode': decode,
	'encode': encode,
	'toASCII': toASCII,
	'toUnicode': toUnicode
};

module.exports = punycode;

Yes, browserify is mainly target convert ES6 to ES5, if browserify itself contain ES6 code.
Than its verfy difficult run in old browser.

Since you can't change it here. Let me try talk to punycode(1.3.2) to remove the uncomfortable amd id('punycode').

@oldmtn
Copy link
Author

oldmtn commented Aug 31, 2018

Besides,
The best thing to do here might be to have a new punycode-browserify package that is punycode 2.0.0 compiled to ES5.

Could you help to do it?

@goto-bus-stop
Copy link
Member

Yes I think I worked on one a few months ago. I'll see if I can dig it up on the weekend.

@ljharb
Copy link
Member

ljharb commented Aug 31, 2018

I'm confused what the problem is with the AMD detection; couldn't that be trivially wrapped for CJS?

@oldmtn oldmtn closed this Aug 31, 2018
@oldmtn oldmtn reopened this Aug 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants