Skip to content

Commit 48f5689

Browse files
committed
[WIP] Use Rollup 🍣 for build
1 parent 596de01 commit 48f5689

File tree

8 files changed

+1017
-1055
lines changed

8 files changed

+1017
-1055
lines changed

package.json

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
"version": "0.12.3",
44
"description": "A toolkit for building WYSIWYG editors with Mobiledoc",
55
"repository": "https://github.com/bustle/mobiledoc-kit",
6+
"module": "dist/index.js",
67
"scripts": {
7-
"start": "broccoli serve --host 0.0.0.0",
8+
"start": "rollup --config --watch",
89
"test:ci": "npm run build:docs && npm run build && testem ci -f testem-ci.js",
9-
"test": "npm run build:docs && npm run build && testem ci -f testem.js",
10-
"build": "rm -rf dist && broccoli build dist",
10+
"test": "rollup --config --tests && testem ci -f testem.js",
11+
"build": "rollup --config",
1112
"build:docs": "jsdoc -c ./.jsdoc",
1213
"build:website": "npm run build && npm run build:docs && ./bin/build-website.sh",
1314
"deploy:website": "./bin/deploy-website.sh",
@@ -23,24 +24,24 @@
2324
"contenteditable"
2425
],
2526
"files": [
26-
"index.js",
27-
"src",
28-
"dist/amd",
29-
"dist/commonjs",
30-
"dist/global",
31-
"dist/css"
27+
"dist/index.js"
3228
],
3329
"author": "Garth Poitras <[email protected]> (http://garthpoitras.com/)",
3430
"contributors": [
31+
"Zahra Jabini <[email protected]> (http://zahraism.com/)",
32+
"Tom Dale <[email protected]> (https://tomdale.net)",
3533
"Cory Forsyth <[email protected]> (http://coryforsyth.com/)",
3634
"Matthew Beale <[email protected]> (http://madhatted.com/)"
3735
],
3836
"license": "MIT",
3937
"dependencies": {
4038
"mobiledoc-dom-renderer": "0.7.0",
41-
"mobiledoc-text-renderer": "0.4.0"
39+
"mobiledoc-text-renderer": "0.4.1"
4240
},
4341
"devDependencies": {
42+
"@rollup/plugin-alias": "^3.0.0",
43+
"@rollup/plugin-commonjs": "^11.0.1",
44+
"@rollup/plugin-node-resolve": "^7.0.0",
4445
"broccoli": "^1.1.3",
4546
"broccoli-babel-transpiler": "^6.1.2",
4647
"broccoli-cli": "^1.0.0",
@@ -53,10 +54,17 @@
5354
"broccoli-test-builder": "^0.4.0",
5455
"conventional-changelog": "^1.1.3",
5556
"conventional-changelog-cli": "^1.3.2",
56-
"jquery": "^3.2.1",
57+
"jquery": "^3.4.1",
5758
"jsdoc": "^3.5.4",
59+
"qunit": "^2.9.3",
60+
"rollup": "^1.31.0",
61+
"rollup-plugin-glob-import": "^0.4.5",
5862
"saucie": "^3.3.2",
5963
"testem": "^2.17.0"
6064
},
61-
"main": "dist/commonjs/mobiledoc-kit/index.js"
65+
"main": "dist/commonjs/mobiledoc-kit/index.js",
66+
"volta": {
67+
"node": "12.14.1",
68+
"yarn": "1.21.1"
69+
}
6270
}

rollup.config.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import globImport from 'rollup-plugin-glob-import';
2+
import alias from '@rollup/plugin-alias';
3+
import resolve from '@rollup/plugin-node-resolve';
4+
import commonjs from '@rollup/plugin-commonjs';
5+
import path from 'path';
6+
7+
export default args => {
8+
if (args.tests) {
9+
return {
10+
input: 'tests/index.js',
11+
plugins: [
12+
resolve(),
13+
commonjs(),
14+
alias({
15+
entries: [
16+
{
17+
find: 'mobiledoc-kit',
18+
replacement: path.join(__dirname, 'src/js')
19+
}
20+
]
21+
}),
22+
globImport()
23+
],
24+
output: {
25+
file: 'dist/tests.js',
26+
format: 'es',
27+
sourcemap: true
28+
}
29+
};
30+
} else {
31+
return {
32+
input: 'src/js/index.js',
33+
plugins: [
34+
resolve(),
35+
commonjs(),
36+
alias({
37+
entries: [
38+
{
39+
find: 'mobiledoc-kit',
40+
replacement: path.join(__dirname, 'src/js')
41+
}
42+
]
43+
}),
44+
],
45+
output: {
46+
file: 'dist/index.js',
47+
format: 'es',
48+
sourcemap: true
49+
}
50+
};
51+
}
52+
};

testem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
module.exports = {
33
"framework": "qunit",
44
"browser_start_timeout": 120,
5-
"test_page": "dist/tests/index.html?hidepassed",
5+
"test_page": "tests/index.rollup.html?hidepassed",
66
"src_files": [
77
"tests/**/*.js",
88
"src/**/*.js"

tests/helpers/module-load-failure.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import $ from "jquery";
2+
window.$ = $;
3+
import "qunit";
4+
5+
import "./unit/**/*.js";
6+
import "./acceptance/**/*.js";

tests/index.rollup.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Mobiledoc Kit tests</title>
6+
<link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css">
7+
<style>
8+
/* position qunit-fixture within view, for easier debugging */
9+
#qunit-fixture {
10+
position: static;
11+
border: 1px solid black;
12+
width: 33%;
13+
height: 33%;
14+
}
15+
</style>
16+
</head>
17+
<body>
18+
19+
<div id="qunit"></div>
20+
<div id="qunit-fixture"></div>
21+
22+
<script src="../dist/tests.js"></script>
23+
<script src="/testem.js"></script>
24+
</body>
25+
</html>

tests/test-helpers.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
import registerAssertions from './helpers/assertions';
33
registerAssertions(QUnit);
44

5-
import registerModuleLoadFailureHandler from './helpers/module-load-failure';
6-
registerModuleLoadFailureHandler(QUnit);
7-
85
import DOMHelpers from './helpers/dom';
96
import MobiledocHelpers from './helpers/mobiledoc';
107
import PostAbstract from './helpers/post-abstract';
@@ -13,7 +10,7 @@ import wait from './helpers/wait';
1310
import MockEditor from './helpers/mock-editor';
1411
import renderBuiltAbstract from './helpers/render-built-abstract';
1512
import run from './helpers/post-editor-run';
16-
import EditorHelpers from './helpers/editor';
13+
import * as EditorHelpers from './helpers/editor';
1714

1815
const { test:qunitTest, module, skip } = QUnit;
1916

0 commit comments

Comments
 (0)