New URL Parser • new URL Parser is same to Browser URL API const URL = require('url').URL; // Create URL Object const u = new URL('https://www.example.com/path/ foo/bar'); // Stringify URL Object u.toString();
New URL Parser • new URL Parser is same to Browser URL API const URL = require('url').URL; // Create URL Object const u = new URL('https://www.example.com/path/ foo/bar'); // Stringify URL Object u.toString(); 8)"58(63-
HTTP/2 Implementation Status • Strongly Work In Progress • Some missing APIs • We have not supported HTTP/2 feature like Server Push/Prioritization yet • We need help!!! • https://github.com/nodejs/http2
ES Modules interoperability is…? • Node.js uses own CommonJS-like module load system. • However JavaScript defines new module system in ES2015. import/export • We need to show users to options to choose both CommonJS and ES Modules style.
ES Modules Goal • new Declarative Grammar • Tools friendly, easy to detect errors • Engines friendly, easy to optimize • new Strict Rules • Module is new Script.
Tools Friendly, Easy to detect errors // export.js export function foo() {} // import.js import { bar } from './export.js'; // Syntax Error, bar is not found.
Engines Friendly, Easy to optimize • MicroSoft Edge experimentally implements ES Modules. • The Browser Engine (Chakra) is optimizing to lookup ES Modules.
ES Modules: new Script • Module is new Script • Module has some differences with current Script • implicit Strict Mode • Different Scope (top level this : undefined) • reserved keywords ( await )
ES Modules // Syntax Error under strict mode, you cannot use with. with (obj) {} // undefined, top level this is undefined not window console.log(this); // it is not window.foo, just module local scope var foo = 1; // Syntax Error, await is reserved in ES Modules var await = 'foo';
Discussion, Discusssion, Discussion… • Loader Spec is under discussion • ES Modules new spec is also under discussion • Node Interop is also under discussion…
new extension?: .mjs • Current Node Proposals looks at file extension • `.js` is Script • `.mjs` is Module • this is still discussing on Node-EPS repository. • https://github.com/nodejs/node-eps/
Note: Babel Behavior is not standard. • if you are using import/export using transpilers like babel, you may change your code to use native ES Modules in the future. The Journey to ES Modules
Features are based on Standard • Past Node.js • Intl built-in Object • Present Node.js • ES 2016+ support • new URL Support • Future Node.js • HTTP/2 • ES Modules &$." &$." 8)"58( *&5' &$."
Why Node needs web standard? James Snell @ NodeFest 2016 Node.js is, and has been, primarily a platform for Web Application Development While Node.js presumes a "small core" philosophy for most things, it includes support for the most basic and critical internet standards
Why Node needs standard? • We are focusing on keep node ecosystems better. • ECMAScript and other internet Standard will be next community standard. • Node.js would be better to follow those standardization
References • You Don’t Know ES Modules by Teppei Sato • Node And Web Standard by James Snell • The Journey to ES Modules by Bradley Ferias • High Performance Browser Networking by Ilya Grigorik • https://github.com/nodejs/node-eps