Skip to content

Commit c1d530b

Browse files
Publish library as ESM and UMD
1 parent 4b6569c commit c1d530b

File tree

4 files changed

+522
-173
lines changed

4 files changed

+522
-173
lines changed

Gruntfile.js

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -89,36 +89,21 @@ module.exports = function (grunt) {
8989
clean: {
9090
all: ["build", "dist"],
9191
},
92-
umd: {
93-
all: {
94-
src: "build/rasterizeHTML.concat.js",
95-
dest: "build/rasterizeHTML.umd.js",
96-
objectToExport: "rasterizeHTML",
97-
indent: " ",
98-
deps: {
99-
default: [
100-
"url",
101-
"xmlserializer",
102-
"sanedomparsererror",
103-
"inlineresources",
104-
],
105-
cjs: [
106-
"url",
107-
"xmlserializer",
108-
"sane-domparser-error",
109-
"inlineresources",
110-
],
111-
amd: [
112-
"url",
113-
"xmlserializer",
114-
"sane-domparser-error",
115-
"inlineresources",
116-
],
117-
},
92+
shell: {
93+
rollup: {
94+
command: "npx rollup -c",
11895
},
11996
},
12097
concat: {
12198
one: {
99+
options: {
100+
banner:
101+
"import url from 'url';\n" +
102+
"import xmlserializer from 'xmlserializer';\n" +
103+
"import sanedomparsererror from 'sane-domparser-error';\n" +
104+
"import inlineresources from 'inlineresources';\n\n",
105+
footer: "\n\nexport default rasterizeHTML;\n",
106+
},
122107
src: [
123108
"src/util.js",
124109
"src/proxies.js",
@@ -132,18 +117,6 @@ module.exports = function (grunt) {
132117
],
133118
dest: "build/rasterizeHTML.concat.js",
134119
},
135-
dist: {
136-
options: {
137-
banner:
138-
"/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
139-
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
140-
"* <%= pkg.homepage %>\n" +
141-
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
142-
" Licensed <%= pkg.license %> */\n",
143-
},
144-
src: ["build/rasterizeHTML.umd.js"],
145-
dest: "dist/<%= pkg.title %>",
146-
},
147120
types: {
148121
options: {
149122
banner:
@@ -169,6 +142,7 @@ module.exports = function (grunt) {
169142
},
170143
files: {
171144
"dist/rasterizeHTML.min.js": ["dist/rasterizeHTML.js"],
145+
"dist/rasterizeHTML.min.mjs": ["dist/rasterizeHTML.mjs"],
172146
},
173147
},
174148
allinone: {
@@ -214,7 +188,7 @@ module.exports = function (grunt) {
214188
grunt.loadNpmTasks("grunt-contrib-watch");
215189
grunt.loadNpmTasks("grunt-contrib-clean");
216190
grunt.loadNpmTasks("grunt-browserify");
217-
grunt.loadNpmTasks("grunt-umd");
191+
grunt.loadNpmTasks("grunt-shell");
218192

219193
grunt.registerTask("deps", [
220194
"browserify:url",
@@ -226,8 +200,7 @@ module.exports = function (grunt) {
226200

227201
grunt.registerTask("build", [
228202
"concat:one",
229-
"umd",
230-
"concat:dist",
203+
"shell:rollup",
231204
"concat:types",
232205
"browserify:allinone",
233206
"uglify",

0 commit comments

Comments
 (0)