From 45fc106314fe0b2806a10a51c2a748fd5d795f7e Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Thu, 17 Oct 2024 09:42:10 -0400 Subject: [PATCH 1/3] drop AMD support from esbuild wrapper --- tasks/util/bundle_wrapper.mjs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tasks/util/bundle_wrapper.mjs b/tasks/util/bundle_wrapper.mjs index 5245bc58c78..189c391027e 100644 --- a/tasks/util/bundle_wrapper.mjs +++ b/tasks/util/bundle_wrapper.mjs @@ -56,9 +56,7 @@ function addWrapper(path){ [ '(', ' function(root, factory) {', - ' if (typeof define === "function" && define.amd) {', - ' define(factory);', - ' } else if (typeof module === "object" && module.exports) {', + ' if (typeof module === "object" && module.exports) {', ' module.exports = factory();', ' } else {', ' root.moduleName = factory();', @@ -73,9 +71,7 @@ function addWrapper(path){ path, [ '', - 'if (!(typeof define === "function" && define.amd)) {', - ' window.Plotly = Plotly;', - '}', + 'window.Plotly = Plotly;', 'return Plotly;', '}));', ].join('\n'), From 2744a4bbe0d7a2e671b3a65a1da7deda165228cb Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Thu, 17 Oct 2024 09:44:04 -0400 Subject: [PATCH 2/3] remove AMD tests --- .circleci/config.yml | 6 ------ package.json | 2 -- tasks/test_amdefine.js | 28 ---------------------------- tasks/test_requirejs.js | 26 -------------------------- 4 files changed, 62 deletions(-) delete mode 100644 tasks/test_amdefine.js delete mode 100644 tasks/test_requirejs.js diff --git a/.circleci/config.yml b/.circleci/config.yml index e0aeb2d6091..008e8c1bea5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -464,12 +464,6 @@ jobs: - run: name: Test plot-schema.json diff - If failed, after (npm start) you could run (npm run schema && git add test/plot-schema.json && git commit -m "update plot-schema diff") command: diff --unified --color dist/plot-schema.json test/plot-schema.json - - run: - name: Test plotly.min.js import using amdefine - command: npm run test-amdefine - - run: - name: Test plotly.min.js import using requirejs - command: npm run test-requirejs test-stackgl-bundle: docker: diff --git a/package.json b/package.json index f0c562db62a..db46f03968e 100644 --- a/package.json +++ b/package.json @@ -47,8 +47,6 @@ "test-export": "node test/image/export_test.js", "test-syntax": "node tasks/test_syntax.js && npm run find-strings -- --no-output", "test-bundle": "node tasks/test_bundle.js", - "test-amdefine": "node tasks/test_amdefine.js", - "test-requirejs": "node tasks/test_requirejs.js", "test-plain-obj": "node tasks/test_plain_obj.mjs", "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", "b64": "python3 test/image/generate_b64_mocks.py && node devtools/test_dashboard/server.mjs", diff --git a/tasks/test_amdefine.js b/tasks/test_amdefine.js deleted file mode 100644 index 7f343e7a775..00000000000 --- a/tasks/test_amdefine.js +++ /dev/null @@ -1,28 +0,0 @@ -var JSDOM = require('jsdom').JSDOM; -global.document = new JSDOM('').window.document; -global.window = document.defaultView; -global.window.document = global.document; -global.self = global.window; -global.Blob = global.window.Blob; -global.DOMParser = global.window.DOMParser; -global.getComputedStyle = global.window.getComputedStyle; -global.window.URL.createObjectURL = function() {}; - -// see: Building node modules with AMD or RequireJS https://requirejs.org/docs/node.html -if(typeof define !== 'function') { - var define = require('amdefine')(module); -} - -define(function(require) { - var plotly = require('../dist/plotly.min.js'); - - if(plotly && plotly.PlotSchema) { - console.log(plotly); - } else { - throw 'Error: loading with amdefine'; - } - - // The value returned from the function is - // used as the module export visible to Node. - return function() {}; -}); diff --git a/tasks/test_requirejs.js b/tasks/test_requirejs.js deleted file mode 100644 index a3a39494e89..00000000000 --- a/tasks/test_requirejs.js +++ /dev/null @@ -1,26 +0,0 @@ -var JSDOM = require('jsdom').JSDOM; -global.document = new JSDOM('').window.document; -global.window = document.defaultView; -global.window.document = global.document; -global.self = global.window; -global.Blob = global.window.Blob; -global.DOMParser = global.window.DOMParser; -global.getComputedStyle = global.window.getComputedStyle; -global.window.URL.createObjectURL = function() {}; - -var requirejs = require('requirejs'); - -requirejs.config({ - paths: { - 'plotly': '../dist/plotly.min' - } -}); - -requirejs(['plotly'], -function(plotly) { - if(plotly && plotly.PlotSchema) { - console.log(plotly); - } else { - throw 'Error: loading with requirejs'; - } -}); From 49258f6b3fa1218662399bb76cf3b4630e6ed9f8 Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Thu, 17 Oct 2024 10:01:05 -0400 Subject: [PATCH 3/3] PR log --- draftlogs/7229_remove.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 draftlogs/7229_remove.md diff --git a/draftlogs/7229_remove.md b/draftlogs/7229_remove.md new file mode 100644 index 00000000000..9305d083052 --- /dev/null +++ b/draftlogs/7229_remove.md @@ -0,0 +1 @@ + - Drop AMD support from bundle header [[#7229](https://github.com/plotly/plotly.js/pull/7229)]