Skip to content

Add option to wrap lib in get() similar to @motiondeveloper/aefunctions - #1

Merged
timhaywood merged 3 commits into
motiondeveloper:wrappingfrom
fartinmartin:master
Oct 18, 2024
Merged

Add option to wrap lib in get() similar to @motiondeveloper/aefunctions#1
timhaywood merged 3 commits into
motiondeveloper:wrappingfrom
fartinmartin:master

Conversation

@fartinmartin

Copy link
Copy Markdown
Contributor

In cases where functions in your library reference other values, like:

// example.jsx
{
  someNumber: 5,
  someFunction(inputParamaters) {
    return someNumber;
  },
}

You will get a ReferenceError: someNumber is not defined expression error. If you attempt to reference via this.someNumber you won't get an expression error, but the value resolves to undefined.

// textLayer.sourceText expression
const { someFunction } = footage("example.jsx").sourceData;
someFunction(); // typeof someFunction() === undefined

You've solved this in your aefunctions.jsx lib by wrapping all of your libs functions in a single getFunctions() method. This PR adds similar functionality to rollup-plugin-ae-jsx via a wrap: true option.

Additionally, this PR will format your .jsx with TypeScript (seems to do a better job than MagicString.trim().indent()) but given that project is written in JavaScript maybe it's not a great idea to introduce TypeScript just for this, haha!

@timhaywood
timhaywood changed the base branch from master to dev October 18, 2024 03:34
@timhaywood
timhaywood merged commit 2bf5e81 into motiondeveloper:wrapping Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants