Skip to content

Commit 80d3090

Browse files
committed
add a publish test for requirejs
1 parent 3781b57 commit 80d3090

File tree

5 files changed

+243
-1
lines changed

5 files changed

+243
-1
lines changed

.circleci/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ jobs:
184184
environment:
185185
NODE_OPTIONS: --max_old_space_size=4096
186186
command: npm run no-dup-keys
187+
- run:
188+
name: Test plotly.min.js import using requirejs
189+
command: npm run test-requirejs
187190

188191
workflows:
189192
version: 2

.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ vendor
33
dist
44
build
55

6+
tasks/test_requirejs.js
67
test/jasmine/assets/jquery-1.8.3.min.js
7-
src/plots/polar/legacy/micropolar.js

package-lock.json

+209
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"test-export": "node tasks/test_export.js",
4343
"test-syntax": "node tasks/test_syntax.js && npm run find-strings -- --no-output",
4444
"test-bundle": "node tasks/test_bundle.js",
45+
"test-requirejs": "node tasks/test_requirejs.js",
4546
"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",
4647
"start-test_dashboard": "node devtools/test_dashboard/server.js",
4748
"start-image_viewer": "node devtools/image_viewer/server.js",
@@ -132,6 +133,7 @@
132133
"browserify": "^17.0.0",
133134
"browserify-transform-tools": "^1.7.0",
134135
"bubleify": "^2.0.0",
136+
"canvas": "^2.6.1",
135137
"check-node-version": "^4.0.3",
136138
"chttps": "^1.0.6",
137139
"deep-equal": "^2.0.5",

tasks/test_requirejs.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
var JSDOM = require('jsdom').JSDOM;
2+
global.document = new JSDOM('<!DOCTYPE html><head></head><html><body></body></html>').window.document;
3+
global.window = document.defaultView;
4+
global.window.document = global.document;
5+
global.self = global.window;
6+
global.Blob = global.window.Blob;
7+
global.DOMParser = global.window.DOMParser;
8+
global.getComputedStyle = global.window.getComputedStyle;
9+
global.window.URL.createObjectURL = function() {};
10+
11+
// see: Building node modules with AMD or RequireJS https://requirejs.org/docs/node.html
12+
if(typeof define !== 'function') {
13+
var define = require('amdefine')(module);
14+
}
15+
16+
define(function(require) {
17+
var plotly = require('../dist/plotly.min.js');
18+
19+
if(plotly) {
20+
console.log(plotly);
21+
} else {
22+
console.error('Error: loading with requirejs');
23+
}
24+
25+
// The value returned from the function is
26+
// used as the module export visible to Node.
27+
return function() {};
28+
});

0 commit comments

Comments
 (0)