diff --git a/.circleci/config.yml b/.circleci/config.yml index 3bf380a338a..4bffa6a65d8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -173,15 +173,20 @@ jobs: - run: name: Test plotly bundles againt unexpected characters command: npm run no-bad-char - - run: - name: Test plotly bundles againt duplicate keys - command: npm run no-dup-keys - run: name: Test certain bundles against function constructors command: npm run no-new-func - run: name: Test plotly bundles against es6 command: npm run no-es6-dist + - run: + name: Test plotly bundles againt duplicate keys + environment: + NODE_OPTIONS: --max_old_space_size=4096 + command: npm run no-dup-keys + - run: + name: Test plotly.min.js import using requirejs + command: npm run test-requirejs workflows: version: 2 diff --git a/.eslintignore b/.eslintignore index 37e5eb77547..944602e142c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,7 @@ node_modules +vendor dist build +tasks/test_requirejs.js test/jasmine/assets/jquery-1.8.3.min.js -src/plots/polar/legacy/micropolar.js diff --git a/devtools/test_dashboard/devtools.js b/devtools/test_dashboard/devtools.js index 9f4974e2be2..1b506b45caf 100644 --- a/devtools/test_dashboard/devtools.js +++ b/devtools/test_dashboard/devtools.js @@ -19,7 +19,7 @@ var Tabs = { Plotly.setPlotConfig({ // use local topojson files - topojsonURL: '../../dist/topojson/', + topojsonURL: '../../vendor/topojson/', // register mapbox access token // run `npm run preset` if you haven't yet diff --git a/devtools/test_dashboard/index.html b/devtools/test_dashboard/index.html index adbf9785223..7e208d3c175 100644 --- a/devtools/test_dashboard/index.html +++ b/devtools/test_dashboard/index.html @@ -19,7 +19,7 @@
- +diff --git a/package-lock.json b/package-lock.json index 09fc60a6fcf..d111e092057 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1719,6 +1719,17 @@ "map-obj": "^1.0.0" } }, + "canvas": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/canvas/-/canvas-2.6.1.tgz", + "integrity": "sha512-S98rKsPcuhfTcYbtF53UIJhcbgIAK533d1kJKMwsMwAIFgfd58MOyxRud3kktlzWiEkFliaJtvyZCBtud/XVEA==", + "dev": true, + "requires": { + "nan": "^2.14.0", + "node-pre-gyp": "^0.11.0", + "simple-get": "^3.0.3" + } + }, "canvas-fit": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/canvas-fit/-/canvas-fit-1.5.0.tgz", @@ -2682,6 +2693,15 @@ "esprima": "4.0.1" } }, + "decompress-response": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz", + "integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==", + "dev": true, + "requires": { + "mimic-response": "^2.0.0" + } + }, "deep-equal": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.0.5.tgz", @@ -3103,6 +3123,12 @@ "resolved": "https://registry.npmjs.org/detect-kerning/-/detect-kerning-2.1.2.tgz", "integrity": "sha512-I3JIbrnKPAntNLl1I6TpSQQdQ4AutYzv/sKMFKbepawV/hlH0GmYKhUoOEMd4xqaUHT+Bm0f4127lh5qs1m1tw==" }, + "detect-libc": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", + "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=", + "dev": true + }, "detective": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.0.tgz", @@ -6491,6 +6517,15 @@ "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", "dev": true }, + "ignore-walk": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.3.tgz", + "integrity": "sha512-m7o6xuOaT1aqheYHKf8W6J5pYH85ZI9w077erOzLje3JsB1gkafkAhHHY19dqjulgIZHFm32Cp5uNZgcQqdJKw==", + "dev": true, + "requires": { + "minimatch": "^3.0.4" + } + }, "image-palette": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/image-palette/-/image-palette-2.1.0.tgz", @@ -8021,6 +8056,12 @@ "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true }, + "mimic-response": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz", + "integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==", + "dev": true + }, "minify-stream": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/minify-stream/-/minify-stream-2.1.0.tgz", @@ -8517,6 +8558,115 @@ } } }, + "node-pre-gyp": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz", + "integrity": "sha512-TwWAOZb0j7e9eGaf9esRx3ZcLaE5tQ2lvYy1pb5IAaG1a2e2Kv5Lms1Y4hpj+ciXJRofIxxlt5haeQ/2ANeE0Q==", + "dev": true, + "requires": { + "detect-libc": "^1.0.2", + "mkdirp": "^0.5.1", + "needle": "^2.2.1", + "nopt": "^4.0.1", + "npm-packlist": "^1.1.6", + "npmlog": "^4.0.2", + "rc": "^1.2.7", + "rimraf": "^2.6.1", + "semver": "^5.3.0", + "tar": "^4" + }, + "dependencies": { + "chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", + "dev": true + }, + "fs-minipass": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz", + "integrity": "sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==", + "dev": true, + "requires": { + "minipass": "^2.6.0" + } + }, + "minipass": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.9.0.tgz", + "integrity": "sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==", + "dev": true, + "requires": { + "safe-buffer": "^5.1.2", + "yallist": "^3.0.0" + } + }, + "minizlib": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.3.3.tgz", + "integrity": "sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==", + "dev": true, + "requires": { + "minipass": "^2.9.0" + } + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, + "nopt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", + "integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==", + "dev": true, + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, + "tar": { + "version": "4.4.13", + "resolved": "https://registry.npmjs.org/tar/-/tar-4.4.13.tgz", + "integrity": "sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA==", + "dev": true, + "requires": { + "chownr": "^1.1.1", + "fs-minipass": "^1.2.5", + "minipass": "^2.8.6", + "minizlib": "^1.2.1", + "mkdirp": "^0.5.0", + "safe-buffer": "^5.1.2", + "yallist": "^3.0.3" + } + }, + "yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true + } + } + }, "node-sass": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-5.0.0.tgz", @@ -8655,6 +8805,15 @@ "resolved": "https://registry.npmjs.org/normals/-/normals-1.1.0.tgz", "integrity": "sha1-MltZXtNK/kZ6bFWhT9kIV4f/WcA=" }, + "npm-bundled": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.1.1.tgz", + "integrity": "sha512-gqkfgGePhTpAEgUsGEgcq1rqPXA+tv/aVBlgEzfXwA1yiUJF7xtEt3CtVwOjNYQOVknDk0F20w58Fnm3EtG0fA==", + "dev": true, + "requires": { + "npm-normalize-package-bin": "^1.0.1" + } + }, "npm-link-check": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/npm-link-check/-/npm-link-check-4.0.0.tgz", @@ -8664,6 +8823,23 @@ "glob": "^7.1.6" } }, + "npm-normalize-package-bin": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz", + "integrity": "sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA==", + "dev": true + }, + "npm-packlist": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.8.tgz", + "integrity": "sha512-5+AZgwru5IevF5ZdnFglB5wNlHG1AOOuw28WhUq8/8emhBmLv6jX5by4WJCh7lW0uSYZYS6DXqIsyZVIXRZU9A==", + "dev": true, + "requires": { + "ignore-walk": "^3.0.1", + "npm-bundled": "^1.0.1", + "npm-normalize-package-bin": "^1.0.1" + } + }, "npmlog": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", @@ -8925,12 +9101,34 @@ "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", "dev": true }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "dev": true + }, "os-shim": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/os-shim/-/os-shim-0.1.3.tgz", "integrity": "sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc=", "dev": true }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "osenv": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "dev": true, + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, "outpipe": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/outpipe/-/outpipe-1.1.1.tgz", @@ -10213,7 +10411,8 @@ "sane-topojson": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/sane-topojson/-/sane-topojson-4.0.0.tgz", - "integrity": "sha512-bJILrpBboQfabG3BNnHI2hZl52pbt80BE09u4WhnrmzuF2JbMKZdl62G5glXskJ46p+gxE2IzOwGj/awR4g8AA==" + "integrity": "sha512-bJILrpBboQfabG3BNnHI2hZl52pbt80BE09u4WhnrmzuF2JbMKZdl62G5glXskJ46p+gxE2IzOwGj/awR4g8AA==", + "dev": true }, "sass-graph": { "version": "2.2.5", @@ -10500,6 +10699,17 @@ "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", "dev": true }, + "simple-get": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.0.tgz", + "integrity": "sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==", + "dev": true, + "requires": { + "decompress-response": "^4.2.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, "simplicial-complex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/simplicial-complex/-/simplicial-complex-1.0.0.tgz", diff --git a/package.json b/package.json index 08e2371031a..538d8fd6b37 100644 --- a/package.json +++ b/package.json @@ -26,12 +26,12 @@ "header-dist": "node tasks/header_dist.js", "stats": "node tasks/stats.js", "find-strings": "node tasks/find_locale_strings.js", - "build": "npm run preprocess && npm run find-strings && npm run bundle && npm run header-dist && npm run stats", - "cibuild": "npm run preprocess && node tasks/cibundle.js", + "build": "node tasks/empty_dist.js && npm run preprocess && node tasks/topojson_dist.js && npm run find-strings && npm run bundle && npm run header-dist && npm run stats", + "cibuild": "node tasks/empty_dist.js && npm run preprocess && node tasks/cibundle.js", "watch": "node tasks/watch.js", "lint": "eslint --version && eslint .", "lint-fix": "eslint . --fix || true", - "no-new-func": "eslint --no-ignore --no-eslintrc --no-inline-config --rule '{no-new-func: error}' $(find dist -type f -iname '*.js' | grep -v plotly-gl* | grep -v plotly-with-meta.* | grep -v plotly.js | grep -v plotly.min.js | grep -v MathJax.js)", + "no-new-func": "eslint --no-ignore --no-eslintrc --no-inline-config --rule '{no-new-func: error}' $(find dist -type f -iname '*.js' | grep -v plotly-gl* | grep -v plotly-with-meta.* | grep -v plotly.js | grep -v plotly.min.js)", "no-bad-char": "eslint --no-ignore --no-eslintrc --no-inline-config --rule '{no-misleading-character-class: error}' $(find dist -type f -iname '*.js' | grep plotly)", "no-dup-keys": "eslint --no-ignore --no-eslintrc --no-inline-config --rule '{no-dupe-keys: error}' $(find dist -type f -iname '*.js' | grep plotly)", "no-es6-dist": "node tasks/no_es6_dist.js", @@ -42,6 +42,7 @@ "test-export": "node tasks/test_export.js", "test-syntax": "node tasks/test_syntax.js && npm run find-strings -- --no-output", "test-bundle": "node tasks/test_bundle.js", + "test-requirejs": "node tasks/test_requirejs.js", "test": "npm run test-jasmine -- --nowatch && npm run test-bundle && npm run test-image && npm run test-export && npm run test-syntax && npm run lint", "start-test_dashboard": "node devtools/test_dashboard/server.js", "start-image_viewer": "node devtools/image_viewer/server.js", @@ -118,7 +119,6 @@ "regl-splom": "^1.0.14", "right-now": "^1.0.0", "robust-orientation": "^1.1.3", - "sane-topojson": "^4.0.0", "strongly-connected-components": "^1.0.1", "superscript-text": "^1.0.0", "svg-path-sdf": "^1.1.3", @@ -133,6 +133,7 @@ "browserify": "^17.0.0", "browserify-transform-tools": "^1.7.0", "bubleify": "^2.0.0", + "canvas": "^2.6.1", "check-node-version": "^4.0.3", "chttps": "^1.0.6", "deep-equal": "^2.0.5", @@ -170,8 +171,8 @@ "prepend-file": "^2.0.0", "prettysize": "^2.0.0", "read-last-lines": "^1.7.2", - "requirejs": "^2.3.6", "run-series": "^1.1.9", + "sane-topojson": "^4.0.0", "through2": "^4.0.2", "true-case-path": "^2.2.1", "watchify": "^3.11.1" diff --git a/tasks/cibundle.js b/tasks/cibundle.js index 7b53995b81e..e904c97f6d9 100644 --- a/tasks/cibundle.js +++ b/tasks/cibundle.js @@ -7,15 +7,15 @@ var _bundle = require('./util/browserify_wrapper'); * Outputs: * * - plotly.js bundle in build/ - * - plotly-geo-assets.js bundle in dist/ (in accordance with test/image/index.html) - * - plotly.min.js bundle in dist/ (for requirejs test) + * - plotly-geo-assets.js bundle in build/ (in accordance with test/image/index.html) + * - plotly.min.js bundle in build/ (for minified_bundle test) */ // Browserify plotly.js and plotly.min.js _bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyBuild, { standalone: 'Plotly', debug: true, - pathToMinBundle: constants.pathToPlotlyDistMin + pathToMinBundle: constants.pathToPlotlyBuildMin }); // Browserify the geo assets diff --git a/tasks/empty_dist.js b/tasks/empty_dist.js new file mode 100644 index 00000000000..ad8197f93f5 --- /dev/null +++ b/tasks/empty_dist.js @@ -0,0 +1,21 @@ +var fs = require('fs-extra'); +var common = require('./util/common'); +var constants = require('./util/constants'); + +// main +emptyDist(); + +function emptyDist() { + var dir = constants.pathToDist; + if(common.doesDirExist(dir)) { + console.log('empty ' + dir); + try { + fs.rmdirSync(dir, { recursive: true }); + } catch(err) { + console.error(err); + } + + // create folder + fs.mkdirSync(dir); + } +} diff --git a/tasks/preprocess.js b/tasks/preprocess.js index f88d9f31cb8..f2ad2da78d2 100644 --- a/tasks/preprocess.js +++ b/tasks/preprocess.js @@ -24,11 +24,11 @@ function makeBuildCSS() { }); } -// copy topojson files from sane-topojson to dist/ +// copy topojson files from sane-topojson to vendor/ function copyTopojsonFiles() { fs.copy( constants.pathToTopojsonSrc, - constants.pathToTopojsonDist, + constants.pathToTopojsonVendor, { clobber: true }, common.throwOnError ); diff --git a/tasks/pretest.js b/tasks/pretest.js index 9ff99fdfb0f..89b6ab3846f 100644 --- a/tasks/pretest.js +++ b/tasks/pretest.js @@ -6,7 +6,6 @@ var common = require('./util/common'); // main makeCredentialsFile(); makeTestImageFolders(); -makeRequireJSFixture(); // Create a credentials json file, // to be required in jasmine test suites and test dashboard @@ -32,20 +31,6 @@ function makeTestImageFolders() { makeOne(constants.pathToTestImagesDiff, 'test image diff folder'); } -// Make script file that define plotly in a RequireJS context -function makeRequireJSFixture() { - var bundle = fs.readFileSync(constants.pathToPlotlyDistMin, 'utf-8'); - - var index = [ - 'define(\'plotly\', function(require, exports, module) {', - bundle, - '});' - ].join(''); - - common.writeFile(constants.pathToRequireJSFixture, index); - logger('make build/requirejs_fixture.js'); -} - function logger(task) { console.log('ok ' + task); } diff --git a/tasks/stats.js b/tasks/stats.js index 31cc04d46e1..3c61593196f 100644 --- a/tasks/stats.js +++ b/tasks/stats.js @@ -58,7 +58,8 @@ function getInfoContent() { '', '```', '', - 'You can grab the relevant MathJax files in `./dist/extras/mathjax/`.', + 'You can get the relevant MathJax files in `./vendor/extras/mathjax/` or from the internet', + 'e.g. "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.3/MathJax.js?config=TeX-AMS-MML_SVG.js"', '', 'By default, plotly.js will modify the global MathJax configuration on load.', 'This can lead to undesirable behavior if plotly.js is loaded alongside', diff --git a/tasks/test_requirejs.js b/tasks/test_requirejs.js new file mode 100644 index 00000000000..2f68561a1bd --- /dev/null +++ b/tasks/test_requirejs.js @@ -0,0 +1,28 @@ +var JSDOM = require('jsdom').JSDOM; +global.document = new JSDOM('