babel-plugin-transform-modules-ui5 7.2.4 → 7.2.5

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 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.2.5](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.2.4...v7.2.5) (2023-08-28)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * by default add "use strict" directive to sap.ui.define ([#115](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/115)) ([7d55cc6](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/commit/7d55cc6126258b60728a00f4070ed19b8ffe9339)), closes [#113](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/issues/113)
12
+
13
+
14
+
15
+
16
+
6
17
  ## [7.2.4](https://github.com/ui5-community/babel-plugin-transform-modules-ui5/compare/v7.2.3...v7.2.4) (2023-07-20)
7
18
 
8
19
 
@@ -89,7 +89,7 @@ function wrap(visitor, programNode, opts) {
89
89
  reachedFirstImport = true;
90
90
  }
91
91
  }
92
- if (preDefine.length && !hasUseStrict(programNode)) {
92
+ if (!opts.neverUseStrict && preDefine.length && !hasUseStrict(programNode)) {
93
93
  programNode.directives = [_core.types.directive(_core.types.directiveLiteral("use strict")), ...(programNode.directives || [])];
94
94
  }
95
95
  body = newBody;
@@ -130,7 +130,14 @@ function wrap(visitor, programNode, opts) {
130
130
  if (imports.some(imp => imp.interop)) {
131
131
  body.unshift(th.buildDefaultImportInterop());
132
132
  }
133
- programNode.body = [...preDefine, generateDefine(body, imports, exportGlobal || opts.exportAllGlobal)];
133
+ const define = generateDefine(body, imports, exportGlobal || opts.exportAllGlobal, hasUseStrict(programNode));
134
+
135
+ // add the "use strict" directive if not on program node
136
+ if (!opts.neverUseStrict && !hasUseStrict(programNode)) {
137
+ const defineFnBody = define.expression.arguments[1].body;
138
+ defineFnBody.directives = [_core.types.directive(_core.types.directiveLiteral("use strict")), ...(defineFnBody.directives || [])];
139
+ }
140
+ programNode.body = [...preDefine, define];
134
141
 
135
142
  // if a copyright comment is present we append it to the new program node
136
143
  if (copyright && visitor.parent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-transform-modules-ui5",
3
- "version": "7.2.4",
3
+ "version": "7.2.5",
4
4
  "description": "An unofficial babel plugin for SAP UI5.",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -94,5 +94,5 @@
94
94
  "prettier": "^3.0.0",
95
95
  "rimraf": "^5.0.1"
96
96
  },
97
- "gitHead": "57a9c2365de4c2ba507905a778ef473de06afa0a"
97
+ "gitHead": "82b76e320c93f90c03a746cab604ddd8e43a2d54"
98
98
  }