-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot define thisLayer
in multiple files
#1
Comments
Hey @kenashcraft I noticed this too! I found that if you create a // globals.ts
import { Layer } from 'expression-globals-typescript';
const thisLayer = new Layer();
export { thisLayer }; // layer.ts
import { thisLayer } from './globals';
function colorDepth(): number {
return thisLayer.colorDepth;
}
export { colorDepth }; // index.ts
import { thisLayer } from './globals';
import { colorDepth } from './layer';
function layerName(): string {
return thisLayer.name;
}
export { layerName, colorDepth }; Output: // ./dist/script.jsx
{
colorDepth() {
return thisLayer.colorDepth;
},
layerName() {
return thisLayer.name;
},
} Update: as I was chuggin' along the // rollup.config.js
plugins: [
replace({
preventAssignment: true,
values: {
_npmVersion: pkg.version,
thisComp$1: 'thisComp',
thisLayer$1: 'thisLayer',
},
}),
// ...
] |
It's work! But still cannot import below code from
|
I'm just getting started with this setup, and it looks amazing! Unfortunately, I quickly ran into a problem when trying to decompose my code into multiple files. I created a new repo using
create-expression-lib
and left everything as it was. Then I added a new file insrc/
for my function. Here is a simplified example:layer.ts
I modified
index.ts
to import this:The generated code includes
thisLayer$1
and After Effects obviously chokes on that.If I import another file that defines
thisLayer
, the generated code will end up withthisLayer
,thisLayer$1
, andthisLayer$2
.The workaround is to keep all of my code in
index.ts
.The text was updated successfully, but these errors were encountered: