Content-Length: 595668 | pFad | http://github.com/fnando/sparkline/commit/951c0d47ab8f8b39b56d0f2cba898f9ec9b6d37b

01 Fix module export. · fnando/sparkline@951c0d4 · GitHub
Skip to content

Commit 951c0d4

Browse files
committed
Fix module export.
1 parent 5021d32 commit 951c0d4

File tree

4 files changed

+62
-26
lines changed

4 files changed

+62
-26
lines changed

.babelrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2-
"presets": ["@babel/preset-env"]
2+
"presets": ["@babel/env"],
3+
"plugins": [
4+
"@babel/plugin-transform-runtime",
5+
"@babel/plugin-proposal-object-rest-spread",
6+
["@babel/plugin-proposal-function-bind", {"loose": true}]
7+
]
38
}

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,25 @@
77
"README.md"
88
],
99
"main": "dist/sparkline.js",
10-
"module": "src/sparkline.js",
11-
"browser": "dist/sparkline.js",
10+
"module": "src/sparkline.commonjs2.js",
1211
"scripts": {
1312
"test": "mocha --require @babel/register \"test/**/*_test.js\"",
14-
"js:dist:expanded": "webpack",
15-
"js:dist:minified": "env NODE_ENV=production webpack",
16-
"dist": "yarn test && yarn js:dist:expanded && yarn js:dist:minified"
13+
"js:dist:commonjs2": "LIBRARY_TARGET=commonjs2 webpack",
14+
"js:dist:browser": "LIBRARY_TARGET=var webpack",
15+
"dist": "rm -rf dist/* && yarn test && yarn js:dist:browser && yarn js:dist:commonjs2"
1716
},
1817
"description": "Generate SVG sparklines with JavaScript without any external dependency.",
1918
"license": "MIT",
2019
"repository": "https://github.com/fnando/sparkline",
2120
"private": false,
2221
"devDependencies": {
2322
"@babel/core": "7.0.x",
24-
"@babel/register": "7.0.x",
23+
"@babel/plugin-proposal-function-bind": "7.0.x",
24+
"@babel/plugin-proposal-object-rest-spread": "x",
25+
"@babel/plugin-transform-runtime": "7.1.x",
2526
"@babel/preset-env": "7.0.x",
27+
"@babel/register": "7.0.x",
28+
"@babel/runtime": "7.0.x",
2629
"babel-loader": "8.0.x",
2730
"jsdom": "11.7.x",
2831
"mocha": "5.0.x",

webpack.config.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
11
const UglifyJSPlugin = require("uglifyjs-webpack-plugin");
2-
let filename;
3-
let plugins = [];
4-
let mode;
5-
6-
if (process.env.NODE_ENV === "production") {
7-
mode = "production";
8-
filename = "sparkline.min.js";
9-
plugins.push(new UglifyJSPlugin({sourceMap: true}));
10-
} else {
11-
mode = "development";
12-
filename = "sparkline.js";
13-
}
2+
const libraryTarget = process.env.LIBRARY_TARGET;
3+
const names = {
4+
var: "sparkline",
5+
commonjs2: "sparkline.commonjs2"
6+
};
147

158
module.exports = {
169
entry: `${__dirname}/src/sparkline.js`,
1710
devtool: "source-map",
1811
target: "web",
19-
mode: mode,
12+
mode: "production",
2013
node: {
2114
fs: "empty"
2215
},
2316

2417
output: {
2518
path: `${__dirname}/dist/`,
26-
filename: filename,
27-
library: "sparkline"
19+
filename: `${names[libraryTarget]}.js`,
20+
library: "sparkline",
21+
libraryTarget: libraryTarget
2822
},
2923

3024
module: {
@@ -37,5 +31,7 @@ module.exports = {
3731
]
3832
},
3933

40-
plugins: plugins
34+
plugins: [
35+
new UglifyJSPlugin({sourceMap: true})
36+
]
4137
};

yarn.lock

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,21 @@
201201
"@babel/helper-remap-async-to-generator" "^7.0.0"
202202
"@babel/plugin-syntax-async-generators" "^7.0.0"
203203

204+
"@babel/plugin-proposal-function-bind@7.0.x":
205+
version "7.0.0"
206+
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-function-bind/-/plugin-proposal-function-bind-7.0.0.tgz#030bb3dd7affb5a0df8326cdd3e9f6776e95a225"
207+
dependencies:
208+
"@babel/helper-plugin-utils" "^7.0.0"
209+
"@babel/plugin-syntax-function-bind" "^7.0.0"
210+
204211
"@babel/plugin-proposal-json-strings@^7.0.0":
205212
version "7.0.0"
206213
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.0.0.tgz#3b4d7b5cf51e1f2e70f52351d28d44fc2970d01e"
207214
dependencies:
208215
"@babel/helper-plugin-utils" "^7.0.0"
209216
"@babel/plugin-syntax-json-strings" "^7.0.0"
210217

211-
"@babel/plugin-proposal-object-rest-spread@^7.0.0":
218+
"@babel/plugin-proposal-object-rest-spread@^7.0.0", "@babel/plugin-proposal-object-rest-spread@x":
212219
version "7.0.0"
213220
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.0.0.tgz#9a17b547f64d0676b6c9cecd4edf74a82ab85e7e"
214221
dependencies:
@@ -236,6 +243,12 @@
236243
dependencies:
237244
"@babel/helper-plugin-utils" "^7.0.0"
238245

246+
"@babel/plugin-syntax-function-bind@^7.0.0":
247+
version "7.0.0"
248+
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-function-bind/-/plugin-syntax-function-bind-7.0.0.tgz#04ad5fac3f68460ef028b1d92abc09781f2e7478"
249+
dependencies:
250+
"@babel/helper-plugin-utils" "^7.0.0"
251+
239252
"@babel/plugin-syntax-json-strings@^7.0.0":
240253
version "7.0.0"
241254
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.0.0.tgz#0d259a68090e15b383ce3710e01d5b23f3770cbd"
@@ -402,6 +415,15 @@
402415
dependencies:
403416
regenerator-transform "^0.13.3"
404417

418+
"@babel/plugin-transform-runtime@7.1.x":
419+
version "7.1.0"
420+
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.1.0.tgz#9f76920d42551bb577e2dc594df229b5f7624b63"
421+
dependencies:
422+
"@babel/helper-module-imports" "^7.0.0"
423+
"@babel/helper-plugin-utils" "^7.0.0"
424+
resolve "^1.8.1"
425+
semver "^5.5.1"
426+
405427
"@babel/plugin-transform-shorthand-properties@^7.0.0":
406428
version "7.0.0"
407429
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.0.0.tgz#85f8af592dcc07647541a0350e8c95c7bf419d15"
@@ -500,6 +522,12 @@
500522
pirates "^4.0.0"
501523
source-map-support "^0.5.9"
502524

525+
"@babel/runtime@7.0.x":
526+
version "7.0.0"
527+
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.0.0.tgz#adeb78fedfc855aa05bc041640f3f6f98e85424c"
528+
dependencies:
529+
regenerator-runtime "^0.12.0"
530+
503531
"@babel/template@^7.0.0":
504532
version "7.0.0"
505533
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0.tgz#c2bc9870405959c89a9c814376a2ecb247838c80"
@@ -3287,6 +3315,10 @@ regenerate@^1.4.0:
32873315
version "1.4.0"
32883316
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11"
32893317

3318+
regenerator-runtime@^0.12.0:
3319+
version "0.12.1"
3320+
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de"
3321+
32903322
regenerator-transform@^0.13.3:
32913323
version "0.13.3"
32923324
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.13.3.tgz#264bd9ff38a8ce24b06e0636496b2c856b57bcbb"
@@ -3423,7 +3455,7 @@ resolve-url@^0.2.1:
34233455
version "0.2.1"
34243456
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
34253457

3426-
resolve@^1.3.2:
3458+
resolve@^1.3.2, resolve@^1.8.1:
34273459
version "1.8.1"
34283460
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26"
34293461
dependencies:
@@ -3515,7 +3547,7 @@ semver@^5.3.0:
35153547
version "5.4.1"
35163548
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"
35173549

3518-
semver@^5.4.1:
3550+
semver@^5.4.1, semver@^5.5.1:
35193551
version "5.5.1"
35203552
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.1.tgz#7dfdd8814bdb7cabc7be0fb1d734cfb66c940477"
35213553

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/fnando/sparkline/commit/951c0d47ab8f8b39b56d0f2cba898f9ec9b6d37b

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy