babel-plugin-transform-modules-ui5 7.1.1 → 7.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/utils/templates.js +62 -10
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [7.1.2](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.1.1...v7.1.2) (2023-04-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* dynamic imports of empty modules must not fail ([#92](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/92)) ([a1de75d](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/a1de75dcfcb577bf6fea3669cf448e9183b7d636))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [7.1.1](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.1.0...v7.1.1) (2023-03-27)
|
|
7
18
|
|
|
8
19
|
|
package/dist/utils/templates.js
CHANGED
|
@@ -85,23 +85,75 @@ const buildDefaultImportDeconstructor = (0, _core.template)(`
|
|
|
85
85
|
const LOCAL = _interopRequireDefault(MODULE);
|
|
86
86
|
`);
|
|
87
87
|
|
|
88
|
+
/*
|
|
89
|
+
* Scenarios for dynamic exports:
|
|
90
|
+
*
|
|
91
|
+
* 1.) ES module with no exports
|
|
92
|
+
*
|
|
93
|
+
* (await import("./moduleWithNoExports.js")) ==> Module
|
|
94
|
+
* (await import("./moduleWithNoExports.js")).default ==> undefined
|
|
95
|
+
*
|
|
96
|
+
* 2.) ES module with default export
|
|
97
|
+
*
|
|
98
|
+
* (await import("./moduleWithDefaultExport.js")) ==> Module
|
|
99
|
+
* (await import("./moduleWithDefaultExport.js")).default ==> DefaultExport
|
|
100
|
+
*
|
|
101
|
+
* 3.) ES module with named exports
|
|
102
|
+
*
|
|
103
|
+
* (await import("./moduleWithNamedExport.js")) ==> Module
|
|
104
|
+
* (await import("./moduleWithNamedExport.js")).default ==> undefined
|
|
105
|
+
* (await import("./moduleWithNamedExport.js")).NamedExport ==> NamedExport
|
|
106
|
+
*
|
|
107
|
+
* A Module object is always returned by the dynamic import.
|
|
108
|
+
*
|
|
109
|
+
* ---
|
|
110
|
+
*
|
|
111
|
+
* The dynamic import script template simulates the default and named exports
|
|
112
|
+
* for non-ES modules so that the TypeScript code completion can be properly
|
|
113
|
+
* used. The template below is used to translate dynamic imports to sap.ui.require
|
|
114
|
+
* calls which are typically be used for the following scenarios:
|
|
115
|
+
*
|
|
116
|
+
* 1.) UI5 Libraries
|
|
117
|
+
*
|
|
118
|
+
* A UI5 library exports its complete namespace and all available
|
|
119
|
+
* types/enums/... are accessible as named properties on that
|
|
120
|
+
* namespace, e.g.:
|
|
121
|
+
*
|
|
122
|
+
* (await import("sap/m/library")) => { __esModule: true, ... }
|
|
123
|
+
* (await import("sap/m/library")).default => undefined
|
|
124
|
+
* (await import("sap/m/library")).ButtonType => sap/m/ButtonType
|
|
125
|
+
*
|
|
126
|
+
* 2.) UI5 Classes
|
|
127
|
+
*
|
|
128
|
+
* A UI5 class exports itself as default. When importing a UI5 class
|
|
129
|
+
* it is expected to be accessible via the default property.
|
|
130
|
+
*
|
|
131
|
+
* (await import("sap/m/Button")) => { __esModule: true, ... }
|
|
132
|
+
* (await import("sap/m/Button")).default => sap/m/Button
|
|
133
|
+
*
|
|
134
|
+
* 3.) Static Helpers (sap/m/MessageBox)
|
|
135
|
+
*
|
|
136
|
+
* (await import("sap/m/MessageBox")) => { __esModule: true, ... }
|
|
137
|
+
* (await import("sap/m/MessageBox")).default => sap/m/MessageBox
|
|
138
|
+
* (await import("sap/m/MessageBox")).Action => undefined
|
|
139
|
+
* (await import("sap/m/MessageBox")).default.Action => sap/m/MessageBox.Action
|
|
140
|
+
*
|
|
141
|
+
* 4.) undefined or null (no exports)
|
|
142
|
+
*
|
|
143
|
+
* (await import("./non/exporting/module")) => { __esModule: true, ... }
|
|
144
|
+
* (await import("./non/exporting/module")) => undefined
|
|
145
|
+
*/
|
|
88
146
|
// TODO: inject __extends instead of Object.assign unless useBuiltIns in set
|
|
89
147
|
exports.buildDefaultImportDeconstructor = buildDefaultImportDeconstructor;
|
|
90
148
|
const buildDynamicImportHelper = (0, _core.template)(`
|
|
91
149
|
function __ui5_require_async(path) {
|
|
92
150
|
return new Promise((resolve, reject) => {
|
|
93
151
|
sap.ui.require([path], (module) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return resolve(module);
|
|
98
|
-
} else if (module.default) {
|
|
99
|
-
return reject(new Error(path + " module includes a 'default' property but not __esModule. Cannot use as dynamic import"));
|
|
100
|
-
} else {
|
|
101
|
-
module.default = typeof module === "object" ? Object.assign({}, module) : module;
|
|
102
|
-
module.__esModule = true;
|
|
103
|
-
resolve(module);
|
|
152
|
+
module = module === null || !(typeof module === "object" && path.endsWith("/library")) ? { default: module } : module;
|
|
153
|
+
if (!module.__esModule) {
|
|
154
|
+
Object.defineProperty(module, "__esModule", { value: true });
|
|
104
155
|
}
|
|
156
|
+
resolve(module);
|
|
105
157
|
}, (err) => {
|
|
106
158
|
reject(err);
|
|
107
159
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-transform-modules-ui5",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.2",
|
|
4
4
|
"description": "An unofficial babel plugin for SAP UI5.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -92,5 +92,5 @@
|
|
|
92
92
|
"prettier": "^2.8.4",
|
|
93
93
|
"rimraf": "^4.1.2"
|
|
94
94
|
},
|
|
95
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "f3aa113c8c8a0294648e93c466e1e298593b4c35"
|
|
96
96
|
}
|