Skip to content

Commit 3b22d20

Browse files
author
Bernat Jufré
committed
feat: add support for ESM module when transpiling code
1 parent 0fc8b3b commit 3b22d20

File tree

33 files changed

+167
-61
lines changed

33 files changed

+167
-61
lines changed

babel.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
const ESM = process.env.ESM === 'true'
2+
13
module.exports = {
24
presets: [['@babel/env', {
35
targets: { node: '10' },
46
include: ['transform-classes'],
7+
...(ESM ? { modules: false } : {}),
58
}]],
69
plugins: [
710
'@babel/proposal-class-properties',

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
"private": true,
44
"scripts": {
55
"build:watch": "lerna run build --parallel -- -- -w",
6-
"build": "lerna run build --parallel --ignore mjml-browser",
6+
"build": "yarn run build:cjs && yarn run build:esm",
7+
"build:cjs": "lerna run build --parallel --ignore mjml-browser",
8+
"build:esm": "cross-env ESM=true lerna run build:esm --parallel --ignore mjml-browser --ignore mjml-cli --ignore mjml-migrate",
79
"build-browser": "cd packages/mjml-browser && yarn build",
810
"lint": "eslint .",
911
"lint:fix": "eslint . --fix",
@@ -22,6 +24,7 @@
2224
"babel-eslint": "^10.1.0",
2325
"babel-plugin-add-module-exports": "^1.0.2",
2426
"babel-plugin-lodash": "^3.3.4",
27+
"cross-env": "^7.0.3",
2528
"eslint": "^6.8.0",
2629
"eslint-config-airbnb-base": "^14.1.0",
2730
"eslint-config-prettier": "^6.11.0",

packages/mjml-accordion/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-accordion",
33
"description": "mjml-accordion",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-body/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-body",
33
"description": "mjml-body",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-button/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-button",
33
"description": "mjml-button",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-carousel/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-carousel",
33
"description": "mjml-carousel",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-column/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-column",
33
"description": "mjml-column",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-core/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-core",
33
"description": "mjml-core",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward",
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward",
2224
"test": "node ./tests/index.js"
2325
},
2426
"dependencies": {

packages/mjml-divider/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-divider",
33
"description": "mjml-divider",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-group/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-group",
33
"description": "mjml-group",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-head-attributes/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-head-attributes",
33
"description": "mjml-head-attributes",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-head-breakpoint/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-head-breakpoint",
33
"description": "mjml-head-breakpoint",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-head-font/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-head-font",
33
"description": "mjml-head-font",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-head-html-attributes/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-head-html-attributes",
33
"description": "mjml-head-html-attributes",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-head-preview/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-head-preview",
33
"description": "mjml-head-preview",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-head-style/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-head-style",
33
"description": "mjml-head-style",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-head-title/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-head-title",
33
"description": "mjml-head-title",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-head/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-head",
33
"description": "mjml-head",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-hero/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-hero",
33
"description": "mjml-hero",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

packages/mjml-image/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "mjml-image",
33
"description": "mjml-image",
44
"version": "4.9.3",
5-
"main": "lib/index.js",
5+
"main": "lib/cjs/index.js",
6+
"module": "lib/esm/index.js",
67
"files": [
78
"lib"
89
],
@@ -18,7 +19,8 @@
1819
"homepage": "https://mjml.io",
1920
"scripts": {
2021
"clean": "rimraf lib",
21-
"build": "babel src --out-dir lib --root-mode upward"
22+
"build": "babel src --out-dir lib/cjs --root-mode upward",
23+
"build:esm": "babel src --out-dir lib/esm --root-mode upward"
2224
},
2325
"dependencies": {
2426
"@babel/runtime": "^7.8.7",

0 commit comments

Comments
 (0)