-
Notifications
You must be signed in to change notification settings - Fork 10
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
Bunch of things #4
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome Koen! Really great stuff. I've got one issue and couple nitpicks that I'd like to review before merging.
Thanks so much!
|
||
// @ts-ignore | ||
const Buffer = cep_node.Buffer | ||
const jsxBundle = readFileSync('./dist/index.js').toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks the build
task for me. The ./dist/index.js
file doesn't exist unless I run the start
task before hand. This was part of the reason why I create the manifest.json
file to confidently grab the transpiled/hashed parcel bundle names and call them at runtime. Like so:
const manifest = fs.readJsonSync(path.join(extensionPath, "manifest.json"));
loadExtendscript(manifest["index.jsx.ts"]);
I'm a little hesitant to remove this feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are bundling the ExtendScript file seperately (as the entry file) it will not get a strange suffix, so we can expect it to be named "index.js" in the dist folder.
Also, to get live reloading capabilities, we have to know the path on forehand, since fs.readJsonSync('some/path')
will be transformed by parcel (at compile time) into a Buffer(withTheContentsOfTheFile)
, it also works with path.join() but only with variables it can figure out at compile time, so not the manifest file (as it's not there yet)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if you want the manifest for other purposes, you can use this plugin: https://www.npmjs.com/package/parcel-plugin-bundle-manifest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm cool with swapping my built-in manifest implementation out for parcel-plugin-bundle-manifest
and also maybe removing it from the starter template. But before we decide that, we should address the error that happens when running build
. This is what I get:
extendscript.tsx:7:34: ENOENT: nosuch file or directory, open '~/Workspace/parcel-plugin-cep-starter/dist/index.js'
5 | // @ts-ignore
6 | var Buffer = cep_node.Buffer;
> 7 | var jsxBundle = fs_1.readFileSync('./dist/index.js').toString();
| ^
8 | cep_interface_1.evalExtendscript(jsxBundle);
9 | var host = cep_interface_1.getHostEnvironment();
Are you not seeing the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not seeing the same, but I just pushed a change that will first run the "clean" and "build-jsx" tasks before starting the watch processes (start-jsx & start-js).
Hope that makes it work for you =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something doesn't feel right with requiring something in dist
from src
. I think we want to keep the manifest way of doing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately we cannot use the manifest file I think since we depend on the bundler to insert the contents of the file at compile time, it works like brfs
(from browserify) if you are familiar with that: https://github.com/browserify/brfs
Without this we cannot have live reload for .jsx files, which is worth the hack I think.
I am not aware of another way of doing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we used https://github.com/kentcdodds/babel-plugin-preval to find the name of the file at compile time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding preval is also a hack, adds another dependency and might be more confusing in the end. My idea about using a process.env variable to get the path is also not going to work since we run 2 different bundlers, 1 for the JS and one for the JSX code, the JS bundler needs to find out the path to the JSX file but that bundler is not aware of the other one, I think we should keep it as it is and add a warning in the readme that when people rename / move the entry file of the extendscript code they also have to update the path in the JS code.
Co-Authored-By: vespakoen <k.schmeets@gmail.com>
package.json
Outdated
"debug": "npm-run-all --parallel debug-jsx debug-js", | ||
"debug-js": "parcel --log-level 4 src/js/index.html", | ||
"debug-jsx": "parcel watch src/jsx/index.ts --no-hmr --no-source-maps --log-level 4", | ||
"build": "npm-run-all clean build-js build-jsx", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"build": "npm-run-all clean build-js build-jsx", | |
"build": "npm-run-all --serial clean build-jsx build-js", |
This seems to fix the error I was experiencing with it not finding ./dist/index.js
and causing the build to break.
I just pushed changes that runs the I also fixed most .ts errors (I have only one left that comes from cep-interface):
And updated the parcel-plugin-cep dependency to version 1.2.0 |
"noLib": true
for ExtendScript'stsconfig.json
and requireextendscript-es5-shim-ts
(should probably see if the babel extendscript transform is still necessary)console.log
support in ExtendScript (which prints to the CEP console)