@siemens/element-ng 48.5.0 → 48.5.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.
@@ -139,31 +139,38 @@ const updateDecoratorImports = (recorder, sourceFile) => {
139
139
  if (!decoratorNode || !ts.isObjectLiteralExpression(decoratorNode)) {
140
140
  return;
141
141
  }
142
- const matchingProperties = getMetadataField(decoratorNode, 'imports');
143
- const importsAssignment = matchingProperties[0];
144
- if (!ts.isPropertyAssignment(importsAssignment) ||
145
- !ts.isArrayLiteralExpression(importsAssignment.initializer)) {
146
- return;
142
+ for (const metaDataField of ['imports', 'exports']) {
143
+ const matchingProperties = getMetadataField(decoratorNode, metaDataField);
144
+ const propertyAssignment = matchingProperties[0];
145
+ if (!propertyAssignment ||
146
+ !ts.isPropertyAssignment(propertyAssignment) ||
147
+ !ts.isArrayLiteralExpression(propertyAssignment.initializer)) {
148
+ continue;
149
+ }
150
+ const elements = propertyAssignment.initializer.elements;
151
+ if (elements.find(e => e.getText() === 'SimplElementNgModule') === undefined) {
152
+ // No SimplElementNgModule found, nothing to do
153
+ continue;
154
+ }
155
+ // Filter out SimplElementNgModule and get existing modules
156
+ const existingModules = elements
157
+ .filter(e => e.getText() !== 'SimplElementNgModule')
158
+ .map(e => e.getText());
159
+ const existingModulesSet = new Set(existingModules);
160
+ // Only add modules that don't already exist
161
+ const newModulesToAdd = SIMPL_ELEMENT_NG_MODULES.filter(m => !existingModulesSet.has(m));
162
+ // Combine existing (without SimplElementNgModule) + new modules
163
+ const allModules = [...existingModules, ...newModulesToAdd];
164
+ // Remove existing imports array
165
+ recorder.remove(propertyAssignment.getFullStart(), propertyAssignment.getFullWidth());
166
+ // Create and insert the updated property assignment
167
+ const printer = ts.createPrinter();
168
+ const newNode = ts.factory.createArrayLiteralExpression(allModules.map(m => ts.factory.createIdentifier(m)), true);
169
+ const newProperty = ts.factory.updatePropertyAssignment(propertyAssignment, propertyAssignment.name, newNode);
170
+ const propertyText = printer.printNode(ts.EmitHint.Unspecified, newProperty, sourceFile);
171
+ // Had to add extra indentation to align properly
172
+ recorder.insertLeft(propertyAssignment.getStart(), `\n ` + propertyText);
147
173
  }
148
- const elements = importsAssignment.initializer.elements;
149
- // Filter out SimplElementNgModule and get existing modules
150
- const existingModules = elements
151
- .filter(e => e.getText() !== 'SimplElementNgModule')
152
- .map(e => e.getText());
153
- const existingModulesSet = new Set(existingModules);
154
- // Only add modules that don't already exist
155
- const newModulesToAdd = SIMPL_ELEMENT_NG_MODULES.filter(m => !existingModulesSet.has(m));
156
- // Combine existing (without SimplElementNgModule) + new modules
157
- const allModules = [...existingModules, ...newModulesToAdd];
158
- // Remove existing imports array
159
- recorder.remove(importsAssignment.getFullStart(), importsAssignment.getFullWidth());
160
- // Create and insert the updated property assignment
161
- const printer = ts.createPrinter();
162
- const newNode = ts.factory.createArrayLiteralExpression(allModules.map(m => ts.factory.createIdentifier(m)), true);
163
- const newProperty = ts.factory.updatePropertyAssignment(importsAssignment, importsAssignment.name, newNode);
164
- const propertyText = printer.printNode(ts.EmitHint.Unspecified, newProperty, sourceFile);
165
- // Had to add extra indentation to align properly
166
- recorder.insertLeft(importsAssignment.getStart(), `\n ` + propertyText);
167
174
  };
168
175
  /**
169
176
  * Removes old import declarations from the file