個人の感想です。
規約
- 相対パスは ECMAScript modules で
import
/export
- それ以外は Common JS で
require
/module.exports
意味
- 内界 - プロジェクト内のコードはECMAScript modulesでやり取り
- 外界 - npmパッケージを
require
や、package.jsonの"main"
へのexportはCommonJSでやり取り
例
const fs = require("fs");
const path = require("path");
const mkdirp = require("mkdirp");
const Promise = require("bluebird");
const debug = require("debug")("textlint:cli");
import options from "./options";
import TextLintEngine from "./textlint-engine";
import TextFixEngine from "./textfix-engine";
import Config from "./config/config";
import configInit from "./config/config-initializer";
import TextLintFixer from "./fixer/textlint-fixer";
import Logger from "./util/logger";
その他
- 8.1.1.5 Module Environment Records
- whatwg/loader: Loader Standard
- 16. Modules
- ES6 module loading: More complicated than you think - NCZOnline
- ES6 Module Detection in Node · nodejs/node Wiki
- TypeScript-Handbook/Namespaces and Modules.md at master · Microsoft/TypeScript-Handbook
- Typings for NPM Packages · TypeScript
- ES6 in Practice
- Webpack 2 Tree Shaking Configuration — Modus Create: Front End Development — Medium