Skip to content

Commit 44f1ac2

Browse files
committed
feat: export only es modules (trivago#89)
1 parent dcf7b50 commit 44f1ac2

File tree

25 files changed

+43
-51
lines changed

25 files changed

+43
-51
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"eslint-config-idiomatic": "^3.1.0",
6666
"eslint-config-prettier": "^2.3.0",
6767
"eslint-plugin-prettier": "^2.1.2",
68+
"esm": "^3.2.9",
6869
"fs-extra": "^7.0.0",
6970
"glob-fs": "^0.1.7",
7071
"husky": "^0.14.3",

packages/melody-code-frame/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
87
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
98
},

packages/melody-compiler/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
87
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
98
},

packages/melody-component/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
87
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js",
98
"coverage": "nyc npm run test"

packages/melody-devtools/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
87
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js",
98
"coverage": "nyc npm run test"

packages/melody-extension-core/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
8-
"build": "mkdir lib; SUPPORT_CJS=true rollup -c ../../rollup.config.js -i src/index.js"
7+
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
98
},
109
"author": "",
1110
"license": "Apache-2.0",

packages/melody-hoc/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
87
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
98
},

packages/melody-idom/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"types": "./built/index.d.ts",
87
"scripts": {
98
"prebuild": "tsc",

packages/melody-loader/__tests__/__snapshots__/integration.spec.js.snap

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@ Object(__WEBPACK_IMPORTED_MODULE_0__template_melody_twig__[\\"a\\" /* default */
2121
\\"use strict\\";
2222
/* WEBPACK VAR INJECTION */(function(process) {/* harmony export (immutable) */ __webpack_exports__[\\"a\\"] = Template;
2323
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_melody_idom__ = __webpack_require__(6);
24-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_melody_idom___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_melody_idom__);
2524
2625
const _template = {};
2726
/* unused harmony export _template */
2827
2928
3029
_template.render = function (_context) {
31-
Object(__WEBPACK_IMPORTED_MODULE_0_melody_idom__[\\"elementOpen\\"])(\\"div\\", null, null);
32-
Object(__WEBPACK_IMPORTED_MODULE_0_melody_idom__[\\"text\\"])(\\"Hello world\\");
33-
Object(__WEBPACK_IMPORTED_MODULE_0_melody_idom__[\\"elementClose\\"])(\\"div\\");
30+
Object(__WEBPACK_IMPORTED_MODULE_0_melody_idom__[\\"b\\" /* elementOpen */])(\\"div\\", null, null);
31+
Object(__WEBPACK_IMPORTED_MODULE_0_melody_idom__[\\"c\\" /* text */])(\\"Hello world\\");
32+
Object(__WEBPACK_IMPORTED_MODULE_0_melody_idom__[\\"a\\" /* elementClose */])(\\"div\\");
3433
};
3534
3635
if (process.env.NODE_ENV !== \\"production\\") {

packages/melody-loader/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
87
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
98
},

packages/melody-loader/src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = function loader(content) {
3434
for (const pluginName of loaderOptions.plugins) {
3535
if (isString(pluginName)) {
3636
try {
37-
args.push(require('melody-plugin-' + pluginName));
37+
args.push(require('melody-plugin-' + pluginName).default);
3838
} catch (e) {
3939
this.emitWarning(
4040
'Could not find plugin ' +

packages/melody-parser/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
87
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
98
},

packages/melody-parser/src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ export {
4949
copyLoc,
5050
createNode,
5151
Types,
52+
Types as TokenTypes,
5253
};

packages/melody-plugin-idom/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
8-
"build": "mkdir lib; SUPPORT_CJS=true rollup -c ../../rollup.config.js -i src/index.js"
7+
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
98
},
109
"author": "",
1110
"license": "Apache-2.0",

packages/melody-plugin-jsx/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
8-
"build": "mkdir lib; SUPPORT_CJS=true rollup -c ../../rollup.config.js -i src/index.js"
7+
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
98
},
109
"author": "",
1110
"license": "Apache-2.0",

packages/melody-plugin-load-functions/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "./lib/index.js",
66
"jsnext:main": "./lib/index.esm.js",
77
"scripts": {
8-
"build": "mkdir lib; SUPPORT_CJS=true rollup -c ../../rollup.config.js -i src/index.js"
8+
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
99
},
1010
"author": "",
1111
"license": "Apache-2.0",

packages/melody-plugin-skip-if/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
8-
"build": "mkdir lib; SUPPORT_CJS=true rollup -c ../../rollup.config.js -i src/index.js"
7+
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
98
},
109
"author": "",
1110
"license": "Apache-2.0",

packages/melody-redux/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
87
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
98
},

packages/melody-runtime/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
87
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
98
},

packages/melody-traverse/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
87
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
98
},

packages/melody-types/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
87
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
98
},

packages/melody-util/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "1.2.0-3",
44
"description": "",
55
"main": "./lib/index.js",
6-
"jsnext:main": "./lib/index.esm.js",
76
"scripts": {
87
"build": "mkdir lib; rollup -c ../../rollup.config.js -i src/index.js"
98
},

rollup.config.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'fs';
22
import path from 'path';
33
import babel from 'rollup-plugin-babel';
44
import json from 'rollup-plugin-json';
5-
import { uglify } from 'rollup-plugin-uglify';
5+
// import { uglify } from 'rollup-plugin-uglify';
66

77
// reads package.json of packages (melody-*) in packages directory
88
const pkg = fs.readFileSync(path.join(process.cwd(), './package.json'));
@@ -15,7 +15,7 @@ const config = {
1515
output: [
1616
{
1717
file: path.resolve(process.cwd(), pkgJSON.main),
18-
format: 'cjs',
18+
format: 'es',
1919
},
2020
],
2121
plugins: [
@@ -31,29 +31,29 @@ const config = {
3131
],
3232
};
3333

34-
/**
35-
* ES module output configuration
36-
*/
37-
const esmModuleOutput = function() {
38-
return {
39-
file: path.resolve(process.cwd(), pkgJSON['jsnext:main']),
40-
format: 'es',
41-
};
42-
};
34+
// /**
35+
// * ES module output configuration
36+
// */
37+
// const esmModuleOutput = function() {
38+
// return {
39+
// file: path.resolve(process.cwd(), pkgJSON['jsnext:main']),
40+
// format: 'es',
41+
// };
42+
// };
4343

44-
// Let's skip ES Modules in production environment
45-
if (pkgJSON['jsnext:main'] && process.env.NODE_ENV !== 'production') {
46-
config.output.push(esmModuleOutput());
47-
}
44+
// // Let's skip ES Modules in production environment
45+
// if (pkgJSON['jsnext:main'] && process.env.NODE_ENV !== 'production') {
46+
// config.output.push(esmModuleOutput());
47+
// }
4848

49-
if (process.env.NODE_ENV === 'production') {
50-
config.plugins.push(
51-
uglify({
52-
mangle: {
53-
toplevel: true,
54-
},
55-
})
56-
);
57-
}
49+
// if (process.env.NODE_ENV === 'production') {
50+
// config.plugins.push(
51+
// uglify({
52+
// mangle: {
53+
// toplevel: true,
54+
// },
55+
// })
56+
// );
57+
// }
5858

5959
export default config;

testsetup/melody-transform.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// eslint-disable-next-line
2+
require = require('esm')(module /*, options*/);
3+
14
const { transformer } = require('../packages/melody-jest-transform');
25

36
// melody plugins

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -2232,6 +2232,11 @@ eslint@^3.17.1:
22322232
text-table "~0.2.0"
22332233
user-home "^2.0.0"
22342234

2235+
esm@^3.2.9:
2236+
version "3.2.9"
2237+
resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.9.tgz#9dca653e3b39f89c3c65c5e84cebfa4af345c10d"
2238+
integrity sha512-mATFs9dpCjnEyNv27z29UNDmJmBBX8zMdcFip7aIOrBRTpLs8SA+6Ek1QtsWfvecAJVeZy+X5D3Z6xZVtUvYdg==
2239+
22352240
espree@^3.4.0:
22362241
version "3.5.4"
22372242
resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.4.tgz#b0f447187c8a8bed944b815a660bddf5deb5d1a7"

0 commit comments

Comments
 (0)