From eb3f0b4824c1e15a2af3a4b7233980f66e7b7408 Mon Sep 17 00:00:00 2001 From: Mohamed Lamine Allal Date: Sun, 25 Dec 2022 17:56:10 +0100 Subject: [PATCH 1/5] feat: implementing globals and porting some modifications - Implementing by reducing globals (no exact mode) - Implementing exact mode by using regex and fallback resolution - Fixing and adding handling of dot only imports to be `_` rather then empty string "" (a change too was made to have it as member and not computed member ) - fixing or updating imports reducing to include Js extension to not do. Just like babel and because it allow importance and exports to work with the same format. Too necessary. - more details on the pr - --- crates/swc_ecma_transforms_module/src/umd.rs | 6 +- .../src/umd/config.rs | 107 ++++++++++++------ 2 files changed, 76 insertions(+), 37 deletions(-) diff --git a/crates/swc_ecma_transforms_module/src/umd.rs b/crates/swc_ecma_transforms_module/src/umd.rs index 1dbe68929b7a..d07fd95a9ad6 100644 --- a/crates/swc_ecma_transforms_module/src/umd.rs +++ b/crates/swc_ecma_transforms_module/src/umd.rs @@ -36,7 +36,7 @@ where C: Comments, { as_folder(Umd { - config: config.build(cm.clone()), + config: config.build(), unresolved_mark, cm, resolver: Resolver::Default, @@ -68,7 +68,7 @@ where C: Comments, { as_folder(Umd { - config: config.build(cm.clone()), + config: config.build(), unresolved_mark, cm, resolver: Resolver::Real { base, resolver }, @@ -445,7 +445,7 @@ where let global_dep = { let dep_name = self.config.global_name(&src_path); let global = global.clone(); - if is_valid_prop_ident(&dep_name) { + if is_valid_prop_ident(&dep_name) || dep_name.eq("_") { global.make_member(quote_ident!(dep_name)) } else { global.computed_member(quote_str!(dep_name)) diff --git a/crates/swc_ecma_transforms_module/src/umd/config.rs b/crates/swc_ecma_transforms_module/src/umd/config.rs index 3fb840eef0b1..740c7ae1888a 100644 --- a/crates/swc_ecma_transforms_module/src/umd/config.rs +++ b/crates/swc_ecma_transforms_module/src/umd/config.rs @@ -3,9 +3,9 @@ use std::collections::HashMap; use inflector::Inflector; use serde::{Deserialize, Serialize}; use swc_atoms::JsWord; -use swc_common::{errors::HANDLER, sync::Lrc, FileName, SourceMap}; -use swc_ecma_ast::{Expr, Ident}; -use swc_ecma_parser::{parse_file_as_expr, Syntax}; +use swc_cached::regex::CachedRegex; +use swc_common::FileName; +use swc_ecma_ast::Ident; use swc_ecma_utils::quote_ident; use super::super::util; @@ -14,58 +14,97 @@ use super::super::util; #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct Config { #[serde(default)] - pub globals: HashMap, + pub globals: Option>, + + #[serde(default)] + pub exact_globals: Option>, #[serde(flatten, default)] pub config: util::Config, } +fn reduce_src(src: &JsWord) -> JsWord { + let mut out = src.clone(); + + let js_ext_regex = CachedRegex::new(r#"\.([cm]?[jt]s|[jt]sx)$"#).unwrap(); + + if out.contains('/') { + out = out.split('/').last().unwrap().into(); + } + + out = JsWord::from(js_ext_regex.replace(&out, "")); + + out = out.to_camel_case().into(); + if (out).eq("") { + out = JsWord::from("_"); + } + out +} + impl Config { - pub(super) fn build(self, cm: Lrc) -> BuiltConfig { + pub(super) fn build(self) -> BuiltConfig { BuiltConfig { config: self.config, - globals: self - .globals - .into_iter() - .map(|(k, v)| { - let parse = |s| { - let fm = cm - .new_source_file(FileName::Custom(format!("", s)), s); - - parse_file_as_expr( - &fm, - Syntax::default(), - Default::default(), - None, - &mut vec![], - ) - .map_err(|e| { - if HANDLER.is_set() { - HANDLER.with(|h| e.into_diagnostic(h).emit()) - } - }) - .unwrap() - }; - (k, parse(v)) - }) - .collect(), + exact_globals: self.exact_globals.as_ref().map(|globals| { + globals + .iter() + .filter_map(|(glb_matcher, glb_map)| { + let regex = CachedRegex::new(glb_matcher); + match regex { + Ok(reg) => Some((reg, glb_map.to_string())), + _ => None, + } + }) + .collect() + }), + globals: self.globals.map(|globals| { + globals + .iter() + .map(|(glb_matcher, glb_map)| { + let reduced_matcher = + reduce_src(&JsWord::from(glb_matcher.as_str())).to_string(); + (reduced_matcher, glb_map.to_string()) + }) + .collect() + }), } } } #[derive(Clone)] pub(super) struct BuiltConfig { #[allow(dead_code)] - pub globals: HashMap>, + pub globals: Option>, + pub exact_globals: Option>, pub config: util::Config, } impl BuiltConfig { pub fn global_name(&self, src: &JsWord) -> JsWord { - if !src.contains('/') { - return src.to_camel_case().into(); + if let Some(globals) = &self.exact_globals { + let matched_mapped_global = globals.iter().find_map(|(regex, map_str)| { + if regex.is_match(src) { + return Some(map_str); + } + None + }); + + if let Some(matched) = matched_mapped_global { + return JsWord::from(matched.as_str()); + } + + return reduce_src(src); + } + + let mapped_src: JsWord = reduce_src(src); + + if let Some(globals) = &self.globals { + if globals.contains_key(&mapped_src.to_string()) { + let mapped_global = globals.get(&mapped_src.to_string()).unwrap(); + return JsWord::from(mapped_global.as_str()); + } } - src.split('/').last().unwrap().to_camel_case().into() + mapped_src } pub fn determine_export_name(&self, filename: FileName) -> Ident { From edeeb3c9efdb198d2b9e14955a5e4158aeab95cd Mon Sep 17 00:00:00 2001 From: Mohamed Lamine Allal Date: Sun, 25 Dec 2022 17:59:34 +0100 Subject: [PATCH 2/5] chore: adding output.*.ts to prettierignore (for output.umd.ts files) - needed for crates/swc_ecma_transforms_module/tests/fixture/common/issue-4456/1/output.umd.ts - there is output.*.js so .ts version make sense --- .prettierignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.prettierignore b/.prettierignore index 9d7a7a820cb0..d930b5b76b9b 100644 --- a/.prettierignore +++ b/.prettierignore @@ -35,6 +35,7 @@ output.mjs index.g.js output.json output.ts +output.*.ts output.css output.min.css output.html From 768dec8a5f12023a2bd592c83e0cbfa84270420a Mon Sep 17 00:00:00 2001 From: Mohamed Lamine Allal Date: Sun, 25 Dec 2022 18:07:01 +0100 Subject: [PATCH 3/5] update: old tests that had to be changed with the new update This commit include the changes proted for already existing tests before this PR update. (only 3) - crates/swc_ecma_transforms_module/tests/fixture/common/issue-4456/1/output.umd.ts is due to the handling of dot imports to `_` that was added. - crates/swc_ecma_transforms_module/tests/fixture/common/issue-578/2/output.umd.js crates/swc_ecma_transforms_module/tests/fixture/common/issue-962/output.umd.js Due to the no Js type extension inclusion in reducing for imports (like babel - check PR for details) --- .../tests/fixture/common/issue-4456/1/output.umd.ts | 2 +- .../tests/fixture/common/issue-578/2/output.umd.js | 2 +- .../tests/fixture/common/issue-962/output.umd.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-4456/1/output.umd.ts b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-4456/1/output.umd.ts index 20b828a45ac5..258fb87c96bc 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-4456/1/output.umd.ts +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-4456/1/output.umd.ts @@ -7,7 +7,7 @@ "@eduzz/houston-tokens/variables/breakpoints", "@emotion/css" ], factory); - else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}, global[""], global.styled, global.breakpoints, global.css); + else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}, global._, global.styled, global.breakpoints, global.css); })(this, function(exports, _, _styled, _breakpoints, _css) { "use strict"; Object.defineProperty(exports, "__esModule", { diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-578/2/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-578/2/output.umd.js index 78434a6170ad..b7c115872618 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-578/2/output.umd.js +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-578/2/output.umd.js @@ -4,7 +4,7 @@ "exports", "./dep.js" ], factory); - else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}, global.depJs); + else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}, global.dep); })(this, function(exports, _depJs) { "use strict"; Object.defineProperty(exports, "__esModule", { diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-962/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-962/output.umd.js index e4736b284c36..a3dfc97f3b74 100644 --- a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-962/output.umd.js +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-962/output.umd.js @@ -5,7 +5,7 @@ "./_root.js", "./stubFalse.js" ], factory); - else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}, global.rootJs, global.stubFalseJs); + else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}, global.root, global.stubFalse); })(this, function(exports1, _rootJs, _stubFalseJs) { "use strict"; Object.defineProperty(exports1, "__esModule", { From 8b6717af1e6361bf81170018313891121b469481 Mon Sep 17 00:00:00 2001 From: Mohamed Lamine Allal Date: Sun, 25 Dec 2022 18:12:09 +0100 Subject: [PATCH 4/5] test: test for dot imports reducing implementation - The readme included in that test explain what that is - the behavior follow how babel do it. - See PR for more details (Like what part of the code is responsible for this) - --- .../issue-6697-fix-dot-import/README.md | 25 +++++++++ .../common/issue-6697-fix-dot-import/input.js | 25 +++++++++ .../issue-6697-fix-dot-import/module.umd.json | 1 + .../issue-6697-fix-dot-import/output.amd.js | 48 +++++++++++++++++ .../issue-6697-fix-dot-import/output.cjs | 36 +++++++++++++ .../issue-6697-fix-dot-import/output.umd.js | 51 +++++++++++++++++++ 6 files changed, 186 insertions(+) create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/README.md create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/input.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/module.umd.json create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/output.amd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/output.cjs create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/output.umd.js diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/README.md b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/README.md new file mode 100644 index 000000000000..ba2f093f19fd --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/README.md @@ -0,0 +1,25 @@ +# Dot imports and there global reducing + +```js +import dot from '.'; +import twoDots from '..'; +``` + +In + +```js +if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}, global.sparkle, global.worldLevel, global.stormJs, global.phenomenaLevels, global.indexJs, global[""]); +``` + +```js +global[""] +``` +is wrong. + +Babel convert it to + +```js +global._ +``` + +This PR about `issue-6697`does fix it. As it was part of the work. diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/input.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/input.js new file mode 100644 index 000000000000..aed4268d469f --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/input.js @@ -0,0 +1,25 @@ +import sparkle from '@themagician/sparkle'; +import worldLevel from './worldLevel'; +import storm from './storm.js'; +import phenomenaLevels from './phenomena.levels'; +import index from './some/index.js'; +import dot from '.'; +import twoDots from '..'; + +export class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} + +export class World { + runExperiement() { + const seed = storm(worldLevel(), phenomenaLevels()); + twoDots(dot(index())); + sparkle(seed); + } + + toString() { + return `World ${worldLevel()} ${storm()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/module.umd.json b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/module.umd.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/module.umd.json @@ -0,0 +1 @@ +{} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/output.amd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/output.amd.js new file mode 100644 index 000000000000..92736bd850fb --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/output.amd.js @@ -0,0 +1,48 @@ +define([ + "require", + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." +], function(require, exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/output.cjs b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/output.cjs new file mode 100644 index 000000000000..92dfc496f0be --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/output.cjs @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); +} +_export(exports, { + Hello: ()=>Hello, + World: ()=>World +}); +const _sparkle = /*#__PURE__*/ _interopRequireDefault(require("@themagician/sparkle")); +const _worldLevel = /*#__PURE__*/ _interopRequireDefault(require("./worldLevel")); +const _stormJs = /*#__PURE__*/ _interopRequireDefault(require("./storm.js")); +const _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(require("./phenomena.levels")); +const _indexJs = /*#__PURE__*/ _interopRequireDefault(require("./some/index.js")); +const _ = /*#__PURE__*/ _interopRequireDefault(require(".")); +const _1 = /*#__PURE__*/ _interopRequireDefault(require("..")); +class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} +class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/output.umd.js new file mode 100644 index 000000000000..734ba1157c8b --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697-fix-dot-import/output.umd.js @@ -0,0 +1,51 @@ +(function(global, factory) { + if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("@themagician/sparkle"), require("./worldLevel"), require("./storm.js"), require("./phenomena.levels"), require("./some/index.js"), require("."), require("..")); + else if (typeof define === "function" && define.amd) define([ + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." + ], factory); + else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}, global.sparkle, global.worldLevel, global.storm, global.phenomenaLevels, global.index, global._, global._); +})(this, function(exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); From d5a98db0a0d59b2733827ec06f0d28da515815b6 Mon Sep 17 00:00:00 2001 From: Mohamed Lamine Allal Date: Sun, 25 Dec 2022 18:18:16 +0100 Subject: [PATCH 5/5] tests: tests for globals feature ## testing no exact globals - testing when globals are in reduced format - when globals are not in reduced format - testing when no globals are provided - testing also with the dot imports _ change and no Js type extension inclusion in reducing change. ## exact mode - testing regex matching - testing order precedency and regex resolution fallback - testing no regex matching ## in all the output and mapping is tested to work correctly --- .../matching-regex-order-precedency/input.js | 25 +++++++++ .../module.umd.json | 9 ++++ .../output.amd.js | 48 +++++++++++++++++ .../output.cjs | 36 +++++++++++++ .../output.umd.js | 51 +++++++++++++++++++ .../exact-globals/matching-regex/input.js | 25 +++++++++ .../matching-regex/module.umd.json | 12 +++++ .../matching-regex/output.amd.js | 48 +++++++++++++++++ .../exact-globals/matching-regex/output.cjs | 36 +++++++++++++ .../matching-regex/output.umd.js | 51 +++++++++++++++++++ .../exact-globals/not-matching-regex/input.js | 25 +++++++++ .../not-matching-regex/module.umd.json | 6 +++ .../not-matching-regex/output.amd.js | 48 +++++++++++++++++ .../not-matching-regex/output.cjs | 36 +++++++++++++ .../not-matching-regex/output.umd.js | 51 +++++++++++++++++++ .../no-globals/empty-globals/input.js | 25 +++++++++ .../no-globals/empty-globals/module.umd.json | 3 ++ .../no-globals/empty-globals/output.amd.js | 48 +++++++++++++++++ .../no-globals/empty-globals/output.cjs | 36 +++++++++++++ .../no-globals/empty-globals/output.umd.js | 51 +++++++++++++++++++ .../no-globals/no-options-passed/input.js | 25 +++++++++ .../no-options-passed/module.umd.json | 1 + .../no-options-passed/output.amd.js | 48 +++++++++++++++++ .../no-globals/no-options-passed/output.cjs | 36 +++++++++++++ .../no-options-passed/output.umd.js | 51 +++++++++++++++++++ .../matching-not-reduced-format/README.md | 13 +++++ .../matching-not-reduced-format/input.js | 25 +++++++++ .../module.umd.json | 11 ++++ .../matching-not-reduced-format/output.amd.js | 48 +++++++++++++++++ .../matching-not-reduced-format/output.cjs | 36 +++++++++++++ .../matching-not-reduced-format/output.umd.js | 51 +++++++++++++++++++ .../matching-reduced-format/README.md | 10 ++++ .../matching-reduced-format/input.js | 25 +++++++++ .../matching-reduced-format/module.umd.json | 11 ++++ .../matching-reduced-format/output.amd.js | 48 +++++++++++++++++ .../matching-reduced-format/output.cjs | 36 +++++++++++++ .../matching-reduced-format/output.umd.js | 51 +++++++++++++++++++ .../with-globals/not-matching/input.js | 25 +++++++++ .../with-globals/not-matching/module.umd.json | 8 +++ .../with-globals/not-matching/output.amd.js | 48 +++++++++++++++++ .../with-globals/not-matching/output.cjs | 36 +++++++++++++ .../with-globals/not-matching/output.umd.js | 51 +++++++++++++++++++ 42 files changed, 1364 insertions(+) create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/input.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/module.umd.json create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/output.amd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/output.cjs create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/output.umd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/input.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/module.umd.json create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/output.amd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/output.cjs create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/output.umd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/input.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/module.umd.json create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/output.amd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/output.cjs create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/output.umd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/input.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/module.umd.json create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/output.amd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/output.cjs create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/output.umd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/input.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/module.umd.json create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/output.amd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/output.cjs create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/output.umd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/README.md create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/input.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/module.umd.json create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/output.amd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/output.cjs create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/output.umd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/README.md create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/input.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/module.umd.json create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/output.amd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/output.cjs create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/output.umd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/input.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/module.umd.json create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/output.amd.js create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/output.cjs create mode 100644 crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/output.umd.js diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/input.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/input.js new file mode 100644 index 000000000000..aed4268d469f --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/input.js @@ -0,0 +1,25 @@ +import sparkle from '@themagician/sparkle'; +import worldLevel from './worldLevel'; +import storm from './storm.js'; +import phenomenaLevels from './phenomena.levels'; +import index from './some/index.js'; +import dot from '.'; +import twoDots from '..'; + +export class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} + +export class World { + runExperiement() { + const seed = storm(worldLevel(), phenomenaLevels()); + twoDots(dot(index())); + sparkle(seed); + } + + toString() { + return `World ${worldLevel()} ${storm()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/module.umd.json b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/module.umd.json new file mode 100644 index 000000000000..9e456e49b688 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/module.umd.json @@ -0,0 +1,9 @@ +{ + "exactGlobals": [ + ["./phenome$", "PHENOMENA_NO_MATCH"], + ["phenomena\\.levels", "PhenomenaFirstMatch"], + ["^.*phenomena\\.*$", "PhenomenaSecondMatch"], + [".*?storm\\.js$", "STORM_JS"], + ["\\.js$", "ANYTHING_JS"] + ] +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/output.amd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/output.amd.js new file mode 100644 index 000000000000..0685b2866c36 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/output.amd.js @@ -0,0 +1,48 @@ +define([ + "require", + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." +], function(require, exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/output.cjs b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/output.cjs new file mode 100644 index 000000000000..92dfc496f0be --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/output.cjs @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); +} +_export(exports, { + Hello: ()=>Hello, + World: ()=>World +}); +const _sparkle = /*#__PURE__*/ _interopRequireDefault(require("@themagician/sparkle")); +const _worldLevel = /*#__PURE__*/ _interopRequireDefault(require("./worldLevel")); +const _stormJs = /*#__PURE__*/ _interopRequireDefault(require("./storm.js")); +const _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(require("./phenomena.levels")); +const _indexJs = /*#__PURE__*/ _interopRequireDefault(require("./some/index.js")); +const _ = /*#__PURE__*/ _interopRequireDefault(require(".")); +const _1 = /*#__PURE__*/ _interopRequireDefault(require("..")); +class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} +class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/output.umd.js new file mode 100644 index 000000000000..6a07611b692b --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex-order-precedency/output.umd.js @@ -0,0 +1,51 @@ +(function(global, factory) { + if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("@themagician/sparkle"), require("./worldLevel"), require("./storm.js"), require("./phenomena.levels"), require("./some/index.js"), require("."), require("..")); + else if (typeof define === "function" && define.amd) define([ + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." + ], factory); + else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}, global.sparkle, global.worldLevel, global.STORM_JS, global.PhenomenaFirstMatch, global.ANYTHING_JS, global._, global._); +})(this, function(exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/input.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/input.js new file mode 100644 index 000000000000..aed4268d469f --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/input.js @@ -0,0 +1,25 @@ +import sparkle from '@themagician/sparkle'; +import worldLevel from './worldLevel'; +import storm from './storm.js'; +import phenomenaLevels from './phenomena.levels'; +import index from './some/index.js'; +import dot from '.'; +import twoDots from '..'; + +export class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} + +export class World { + runExperiement() { + const seed = storm(worldLevel(), phenomenaLevels()); + twoDots(dot(index())); + sparkle(seed); + } + + toString() { + return `World ${worldLevel()} ${storm()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/module.umd.json b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/module.umd.json new file mode 100644 index 000000000000..29fc5125dca4 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/module.umd.json @@ -0,0 +1,12 @@ +{ + "exactGlobals": [ + ["@themagician/sparkle", "MatchedTMSparkle"], + ["\\./worldLevel", "MatchedWorldLevel"], + ["\\./storm\\.js", "MatchedStormJs"], + ["phenomena\\..*?$", "MatchedPhenomenaLevels"], + ["\\./some/index\\..*$", "MatchedIndexJs"], + ["^(\\.*?/*\\.*)*$", "Matched_"], + ["(^|.*?/)input$", "WorldLib"], + [".*NOMatch", "NO_MATCH"] + ] +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/output.amd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/output.amd.js new file mode 100644 index 000000000000..0685b2866c36 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/output.amd.js @@ -0,0 +1,48 @@ +define([ + "require", + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." +], function(require, exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/output.cjs b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/output.cjs new file mode 100644 index 000000000000..92dfc496f0be --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/output.cjs @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); +} +_export(exports, { + Hello: ()=>Hello, + World: ()=>World +}); +const _sparkle = /*#__PURE__*/ _interopRequireDefault(require("@themagician/sparkle")); +const _worldLevel = /*#__PURE__*/ _interopRequireDefault(require("./worldLevel")); +const _stormJs = /*#__PURE__*/ _interopRequireDefault(require("./storm.js")); +const _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(require("./phenomena.levels")); +const _indexJs = /*#__PURE__*/ _interopRequireDefault(require("./some/index.js")); +const _ = /*#__PURE__*/ _interopRequireDefault(require(".")); +const _1 = /*#__PURE__*/ _interopRequireDefault(require("..")); +class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} +class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/output.umd.js new file mode 100644 index 000000000000..2cd4d40c8115 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/matching-regex/output.umd.js @@ -0,0 +1,51 @@ +(function(global, factory) { + if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("@themagician/sparkle"), require("./worldLevel"), require("./storm.js"), require("./phenomena.levels"), require("./some/index.js"), require("."), require("..")); + else if (typeof define === "function" && define.amd) define([ + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." + ], factory); + else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.WorldLib = {}, global.MatchedTMSparkle, global.MatchedWorldLevel, global.MatchedStormJs, global.MatchedPhenomenaLevels, global.MatchedIndexJs, global.Matched_, global.Matched_); +})(this, function(exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/input.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/input.js new file mode 100644 index 000000000000..aed4268d469f --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/input.js @@ -0,0 +1,25 @@ +import sparkle from '@themagician/sparkle'; +import worldLevel from './worldLevel'; +import storm from './storm.js'; +import phenomenaLevels from './phenomena.levels'; +import index from './some/index.js'; +import dot from '.'; +import twoDots from '..'; + +export class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} + +export class World { + runExperiement() { + const seed = storm(worldLevel(), phenomenaLevels()); + twoDots(dot(index())); + sparkle(seed); + } + + toString() { + return `World ${worldLevel()} ${storm()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/module.umd.json b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/module.umd.json new file mode 100644 index 000000000000..83c130b7b503 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/module.umd.json @@ -0,0 +1,6 @@ +{ + "exactGlobals": [ + ["^NotMatching1$", "NotMatching"], + ["^NotMa.*?tching2$", "NotMatching2"] + ] +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/output.amd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/output.amd.js new file mode 100644 index 000000000000..0685b2866c36 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/output.amd.js @@ -0,0 +1,48 @@ +define([ + "require", + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." +], function(require, exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/output.cjs b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/output.cjs new file mode 100644 index 000000000000..92dfc496f0be --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/output.cjs @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); +} +_export(exports, { + Hello: ()=>Hello, + World: ()=>World +}); +const _sparkle = /*#__PURE__*/ _interopRequireDefault(require("@themagician/sparkle")); +const _worldLevel = /*#__PURE__*/ _interopRequireDefault(require("./worldLevel")); +const _stormJs = /*#__PURE__*/ _interopRequireDefault(require("./storm.js")); +const _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(require("./phenomena.levels")); +const _indexJs = /*#__PURE__*/ _interopRequireDefault(require("./some/index.js")); +const _ = /*#__PURE__*/ _interopRequireDefault(require(".")); +const _1 = /*#__PURE__*/ _interopRequireDefault(require("..")); +class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} +class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/output.umd.js new file mode 100644 index 000000000000..734ba1157c8b --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/exact-globals/not-matching-regex/output.umd.js @@ -0,0 +1,51 @@ +(function(global, factory) { + if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("@themagician/sparkle"), require("./worldLevel"), require("./storm.js"), require("./phenomena.levels"), require("./some/index.js"), require("."), require("..")); + else if (typeof define === "function" && define.amd) define([ + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." + ], factory); + else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}, global.sparkle, global.worldLevel, global.storm, global.phenomenaLevels, global.index, global._, global._); +})(this, function(exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/input.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/input.js new file mode 100644 index 000000000000..aed4268d469f --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/input.js @@ -0,0 +1,25 @@ +import sparkle from '@themagician/sparkle'; +import worldLevel from './worldLevel'; +import storm from './storm.js'; +import phenomenaLevels from './phenomena.levels'; +import index from './some/index.js'; +import dot from '.'; +import twoDots from '..'; + +export class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} + +export class World { + runExperiement() { + const seed = storm(worldLevel(), phenomenaLevels()); + twoDots(dot(index())); + sparkle(seed); + } + + toString() { + return `World ${worldLevel()} ${storm()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/module.umd.json b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/module.umd.json new file mode 100644 index 000000000000..87c454472a84 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/module.umd.json @@ -0,0 +1,3 @@ +{ + "globals": {} +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/output.amd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/output.amd.js new file mode 100644 index 000000000000..92736bd850fb --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/output.amd.js @@ -0,0 +1,48 @@ +define([ + "require", + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." +], function(require, exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/output.cjs b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/output.cjs new file mode 100644 index 000000000000..92dfc496f0be --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/output.cjs @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); +} +_export(exports, { + Hello: ()=>Hello, + World: ()=>World +}); +const _sparkle = /*#__PURE__*/ _interopRequireDefault(require("@themagician/sparkle")); +const _worldLevel = /*#__PURE__*/ _interopRequireDefault(require("./worldLevel")); +const _stormJs = /*#__PURE__*/ _interopRequireDefault(require("./storm.js")); +const _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(require("./phenomena.levels")); +const _indexJs = /*#__PURE__*/ _interopRequireDefault(require("./some/index.js")); +const _ = /*#__PURE__*/ _interopRequireDefault(require(".")); +const _1 = /*#__PURE__*/ _interopRequireDefault(require("..")); +class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} +class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/output.umd.js new file mode 100644 index 000000000000..734ba1157c8b --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/empty-globals/output.umd.js @@ -0,0 +1,51 @@ +(function(global, factory) { + if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("@themagician/sparkle"), require("./worldLevel"), require("./storm.js"), require("./phenomena.levels"), require("./some/index.js"), require("."), require("..")); + else if (typeof define === "function" && define.amd) define([ + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." + ], factory); + else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}, global.sparkle, global.worldLevel, global.storm, global.phenomenaLevels, global.index, global._, global._); +})(this, function(exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/input.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/input.js new file mode 100644 index 000000000000..aed4268d469f --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/input.js @@ -0,0 +1,25 @@ +import sparkle from '@themagician/sparkle'; +import worldLevel from './worldLevel'; +import storm from './storm.js'; +import phenomenaLevels from './phenomena.levels'; +import index from './some/index.js'; +import dot from '.'; +import twoDots from '..'; + +export class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} + +export class World { + runExperiement() { + const seed = storm(worldLevel(), phenomenaLevels()); + twoDots(dot(index())); + sparkle(seed); + } + + toString() { + return `World ${worldLevel()} ${storm()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/module.umd.json b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/module.umd.json new file mode 100644 index 000000000000..0967ef424bce --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/module.umd.json @@ -0,0 +1 @@ +{} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/output.amd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/output.amd.js new file mode 100644 index 000000000000..92736bd850fb --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/output.amd.js @@ -0,0 +1,48 @@ +define([ + "require", + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." +], function(require, exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/output.cjs b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/output.cjs new file mode 100644 index 000000000000..92dfc496f0be --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/output.cjs @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); +} +_export(exports, { + Hello: ()=>Hello, + World: ()=>World +}); +const _sparkle = /*#__PURE__*/ _interopRequireDefault(require("@themagician/sparkle")); +const _worldLevel = /*#__PURE__*/ _interopRequireDefault(require("./worldLevel")); +const _stormJs = /*#__PURE__*/ _interopRequireDefault(require("./storm.js")); +const _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(require("./phenomena.levels")); +const _indexJs = /*#__PURE__*/ _interopRequireDefault(require("./some/index.js")); +const _ = /*#__PURE__*/ _interopRequireDefault(require(".")); +const _1 = /*#__PURE__*/ _interopRequireDefault(require("..")); +class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} +class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/output.umd.js new file mode 100644 index 000000000000..734ba1157c8b --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/no-globals/no-options-passed/output.umd.js @@ -0,0 +1,51 @@ +(function(global, factory) { + if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("@themagician/sparkle"), require("./worldLevel"), require("./storm.js"), require("./phenomena.levels"), require("./some/index.js"), require("."), require("..")); + else if (typeof define === "function" && define.amd) define([ + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." + ], factory); + else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}, global.sparkle, global.worldLevel, global.storm, global.phenomenaLevels, global.index, global._, global._); +})(this, function(exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/README.md b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/README.md new file mode 100644 index 000000000000..67baeed449cb --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/README.md @@ -0,0 +1,13 @@ +This fixture test when the globals matchers are not in the reduced format. And so they need to be reduced. + +Example: + +```json +// not reduced -----> // reduced +./phenomena.levels phenomenaLevels +./some/index.js someIndex +. _ +input.js input +``` + +The files are reduced without file extension because \ No newline at end of file diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/input.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/input.js new file mode 100644 index 000000000000..aed4268d469f --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/input.js @@ -0,0 +1,25 @@ +import sparkle from '@themagician/sparkle'; +import worldLevel from './worldLevel'; +import storm from './storm.js'; +import phenomenaLevels from './phenomena.levels'; +import index from './some/index.js'; +import dot from '.'; +import twoDots from '..'; + +export class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} + +export class World { + runExperiement() { + const seed = storm(worldLevel(), phenomenaLevels()); + twoDots(dot(index())); + sparkle(seed); + } + + toString() { + return `World ${worldLevel()} ${storm()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/module.umd.json b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/module.umd.json new file mode 100644 index 000000000000..5b5ef4dadd5e --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/module.umd.json @@ -0,0 +1,11 @@ +{ + "globals": { + "@themagician/sparkle": "MatchedTMSparkle", + "./worldLevel": "MatchedWorldLevel", + "./storm.js": "MatchedStormJs", + "./phenomena.levels": "MatchedPhenomenaLevels", + "./some/index.js": "MatchedIndexJs", + ".": "Matched_", + "input": "WorldLib" + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/output.amd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/output.amd.js new file mode 100644 index 000000000000..92736bd850fb --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/output.amd.js @@ -0,0 +1,48 @@ +define([ + "require", + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." +], function(require, exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/output.cjs b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/output.cjs new file mode 100644 index 000000000000..92dfc496f0be --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/output.cjs @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); +} +_export(exports, { + Hello: ()=>Hello, + World: ()=>World +}); +const _sparkle = /*#__PURE__*/ _interopRequireDefault(require("@themagician/sparkle")); +const _worldLevel = /*#__PURE__*/ _interopRequireDefault(require("./worldLevel")); +const _stormJs = /*#__PURE__*/ _interopRequireDefault(require("./storm.js")); +const _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(require("./phenomena.levels")); +const _indexJs = /*#__PURE__*/ _interopRequireDefault(require("./some/index.js")); +const _ = /*#__PURE__*/ _interopRequireDefault(require(".")); +const _1 = /*#__PURE__*/ _interopRequireDefault(require("..")); +class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} +class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/output.umd.js new file mode 100644 index 000000000000..2cd4d40c8115 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-not-reduced-format/output.umd.js @@ -0,0 +1,51 @@ +(function(global, factory) { + if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("@themagician/sparkle"), require("./worldLevel"), require("./storm.js"), require("./phenomena.levels"), require("./some/index.js"), require("."), require("..")); + else if (typeof define === "function" && define.amd) define([ + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." + ], factory); + else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.WorldLib = {}, global.MatchedTMSparkle, global.MatchedWorldLevel, global.MatchedStormJs, global.MatchedPhenomenaLevels, global.MatchedIndexJs, global.Matched_, global.Matched_); +})(this, function(exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/README.md b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/README.md new file mode 100644 index 000000000000..297e2aa7f11a --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/README.md @@ -0,0 +1,10 @@ +This fixture test when the globals are directly in the reduced format. + +Example: + +```json +// not reduced -----> // reduced +./phenomena.levels phenomenaLevels +./some/index.js someIndexJs +. _ +``` \ No newline at end of file diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/input.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/input.js new file mode 100644 index 000000000000..aed4268d469f --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/input.js @@ -0,0 +1,25 @@ +import sparkle from '@themagician/sparkle'; +import worldLevel from './worldLevel'; +import storm from './storm.js'; +import phenomenaLevels from './phenomena.levels'; +import index from './some/index.js'; +import dot from '.'; +import twoDots from '..'; + +export class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} + +export class World { + runExperiement() { + const seed = storm(worldLevel(), phenomenaLevels()); + twoDots(dot(index())); + sparkle(seed); + } + + toString() { + return `World ${worldLevel()} ${storm()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/module.umd.json b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/module.umd.json new file mode 100644 index 000000000000..aa7f2451e437 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/module.umd.json @@ -0,0 +1,11 @@ +{ + "globals": { + "sparkle": "MatchedTMSparkle", + "worldLevel": "MatchedWorldLevel", + "storm": "MatchedStormJs", + "phenomenaLevels": "MatchedPhenomenaLevels", + "index": "MatchedIndexJs", + "_": "Matched_", + "input": "WorldLib" + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/output.amd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/output.amd.js new file mode 100644 index 000000000000..92736bd850fb --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/output.amd.js @@ -0,0 +1,48 @@ +define([ + "require", + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." +], function(require, exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/output.cjs b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/output.cjs new file mode 100644 index 000000000000..92dfc496f0be --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/output.cjs @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); +} +_export(exports, { + Hello: ()=>Hello, + World: ()=>World +}); +const _sparkle = /*#__PURE__*/ _interopRequireDefault(require("@themagician/sparkle")); +const _worldLevel = /*#__PURE__*/ _interopRequireDefault(require("./worldLevel")); +const _stormJs = /*#__PURE__*/ _interopRequireDefault(require("./storm.js")); +const _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(require("./phenomena.levels")); +const _indexJs = /*#__PURE__*/ _interopRequireDefault(require("./some/index.js")); +const _ = /*#__PURE__*/ _interopRequireDefault(require(".")); +const _1 = /*#__PURE__*/ _interopRequireDefault(require("..")); +class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} +class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/output.umd.js new file mode 100644 index 000000000000..2cd4d40c8115 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/matching-reduced-format/output.umd.js @@ -0,0 +1,51 @@ +(function(global, factory) { + if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("@themagician/sparkle"), require("./worldLevel"), require("./storm.js"), require("./phenomena.levels"), require("./some/index.js"), require("."), require("..")); + else if (typeof define === "function" && define.amd) define([ + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." + ], factory); + else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.WorldLib = {}, global.MatchedTMSparkle, global.MatchedWorldLevel, global.MatchedStormJs, global.MatchedPhenomenaLevels, global.MatchedIndexJs, global.Matched_, global.Matched_); +})(this, function(exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/input.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/input.js new file mode 100644 index 000000000000..aed4268d469f --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/input.js @@ -0,0 +1,25 @@ +import sparkle from '@themagician/sparkle'; +import worldLevel from './worldLevel'; +import storm from './storm.js'; +import phenomenaLevels from './phenomena.levels'; +import index from './some/index.js'; +import dot from '.'; +import twoDots from '..'; + +export class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} + +export class World { + runExperiement() { + const seed = storm(worldLevel(), phenomenaLevels()); + twoDots(dot(index())); + sparkle(seed); + } + + toString() { + return `World ${worldLevel()} ${storm()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/module.umd.json b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/module.umd.json new file mode 100644 index 000000000000..535cdc56f940 --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/module.umd.json @@ -0,0 +1,8 @@ +{ + "globals": { + "SomeNoMatchingGlob": "TMSparkle", + "dingDang": "TheMagician", + "./some/worldLevel.js.some": "Dragon", + "phenomena": "StormS" + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/output.amd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/output.amd.js new file mode 100644 index 000000000000..92736bd850fb --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/output.amd.js @@ -0,0 +1,48 @@ +define([ + "require", + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." +], function(require, exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +}); diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/output.cjs b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/output.cjs new file mode 100644 index 000000000000..92dfc496f0be --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/output.cjs @@ -0,0 +1,36 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); +} +_export(exports, { + Hello: ()=>Hello, + World: ()=>World +}); +const _sparkle = /*#__PURE__*/ _interopRequireDefault(require("@themagician/sparkle")); +const _worldLevel = /*#__PURE__*/ _interopRequireDefault(require("./worldLevel")); +const _stormJs = /*#__PURE__*/ _interopRequireDefault(require("./storm.js")); +const _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(require("./phenomena.levels")); +const _indexJs = /*#__PURE__*/ _interopRequireDefault(require("./some/index.js")); +const _ = /*#__PURE__*/ _interopRequireDefault(require(".")); +const _1 = /*#__PURE__*/ _interopRequireDefault(require("..")); +class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } +} +class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } +} diff --git a/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/output.umd.js b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/output.umd.js new file mode 100644 index 000000000000..734ba1157c8b --- /dev/null +++ b/crates/swc_ecma_transforms_module/tests/fixture/common/issue-6697/reduced-globals/with-globals/not-matching/output.umd.js @@ -0,0 +1,51 @@ +(function(global, factory) { + if (typeof module === "object" && typeof module.exports === "object") factory(exports, require("@themagician/sparkle"), require("./worldLevel"), require("./storm.js"), require("./phenomena.levels"), require("./some/index.js"), require("."), require("..")); + else if (typeof define === "function" && define.amd) define([ + "exports", + "@themagician/sparkle", + "./worldLevel", + "./storm.js", + "./phenomena.levels", + "./some/index.js", + ".", + ".." + ], factory); + else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}, global.sparkle, global.worldLevel, global.storm, global.phenomenaLevels, global.index, global._, global._); +})(this, function(exports, _sparkle, _worldLevel, _stormJs, _phenomenaLevels, _indexJs, _, _1) { + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + Hello: ()=>Hello, + World: ()=>World + }); + _sparkle = /*#__PURE__*/ _interopRequireDefault(_sparkle); + _worldLevel = /*#__PURE__*/ _interopRequireDefault(_worldLevel); + _stormJs = /*#__PURE__*/ _interopRequireDefault(_stormJs); + _phenomenaLevels = /*#__PURE__*/ _interopRequireDefault(_phenomenaLevels); + _indexJs = /*#__PURE__*/ _interopRequireDefault(_indexJs); + _ = /*#__PURE__*/ _interopRequireDefault(_); + _1 = /*#__PURE__*/ _interopRequireDefault(_1); + class Hello { + message(to) { + console.log(`Hello ${to.toString()}!`); + } + } + class World { + runExperiement() { + const seed = (0, _stormJs.default)((0, _worldLevel.default)(), (0, _phenomenaLevels.default)()); + (0, _1.default)((0, _.default)((0, _indexJs.default)())); + (0, _sparkle.default)(seed); + } + toString() { + return `World ${(0, _worldLevel.default)()} ${(0, _stormJs.default)()}`; + } + } +});