cube icon indicating copy to clipboard operation
cube copied to clipboard

fix(schema-compiler): ExportNamedDeclaration for variables object

Open arkadiusz-swierczek-pm opened this issue 4 months ago • 1 comments

Check List

  • [ ] Tests has been run in packages where changes made if available
  • [x] Linter has been run for changed code
  • [ ] Tests for the changes have been added if not covered yet
  • [ ] Docs have been added / updated if required

Class ImportExportTranspiler contains a bug that prevent using exported object syntax from cubes.

Related: https://cube.dev/docs/product/data-modeling/dynamic/code-reusability-export-and-import#import-from-parent-directories

The changes were tesed using https://astexplorer.net/ and content:

export const helperFunction = () => 'hello'
export { helperFunction as alias }
export default helperFunction

Without the fix, the Compiler throws error TypeError: Cannot read properties of null (reading 'declarations'). After the fix the babel transpiles the file to:

const helperFunction = () => 'hello';

addExport({
  helperFunction: helperFunction
})
addExport({
  alias: helperFunction
});
setExport(helperFunction);

arkadiusz-swierczek-pm avatar Oct 03 '24 15:10 arkadiusz-swierczek-pm