Skip to content

Conversation

@arkadiusz-swierczek-pm
Copy link
Contributor

@arkadiusz-swierczek-pm arkadiusz-swierczek-pm commented Oct 3, 2024

Check List

  • Tests has been run in packages where changes made if available
  • 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 arkadiusz-swierczek-pm requested a review from a team as a code owner October 3, 2024 15:33
@vercel
Copy link

vercel bot commented Oct 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-angular-dashboard ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 3:34pm
examples-react-d3 ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 3:34pm
examples-react-dashboard ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 3:34pm
examples-react-data-table ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 3:34pm
examples-react-highcharts ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 3:34pm
examples-react-material-ui ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 3:34pm
examples-react-pivot-table ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 3:34pm
examples-vue-query-builder ⬜️ Ignored (Inspect) Visit Preview Oct 3, 2024 3:34pm

@github-actions github-actions bot added the pr:community Contribution from Cube.js community members. label Oct 3, 2024
Copy link
Member

@KSDaemon KSDaemon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻 Looks good! @arkadiusz-swierczek-pm thnx for fixing this!

@KSDaemon
Copy link
Member

KSDaemon commented Mar 5, 2025

@arkadiusz-swierczek-pm, it would be awesome if you could add a kind of basic test for this in transpilers.test.ts

if ('declaration' in path.node && path.node.declaration) {
path.replaceWithMultiple([
// @todo fix without any
(<any>path.get('declaration')).node,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I can see, path.get('declaration') is still used in path.replaceWithMultiple.
Two different nodes in if condition and replaceWithMultiple call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:community Contribution from Cube.js community members.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants