Skip to content
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

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Conversation

vespakoen
Copy link

  • Add live reloading for ExtendScript code
  • yarn -> npm
  • add debug start script that will show verbose logs
  • use "noLib": true for ExtendScript's tsconfig.json and require extendscript-es5-shim-ts (should probably see if the babel extendscript transform is still necessary)
  • assume the environment is CEP
  • add bridge to communicate from ExtendScript to CEP
  • add console.log support in ExtendScript (which prints to the CEP console)
  • assume the environment is always CEP / get rid of all the isCEPEnvironment

Copy link
Owner

@fusepilot fusepilot left a 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()
Copy link
Owner

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.

Copy link
Author

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)

Copy link
Author

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

Copy link
Owner

@fusepilot fusepilot Oct 20, 2018

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?

Copy link
Author

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 =)

Copy link
Owner

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.

Copy link
Author

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.

Copy link
Owner

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?

Copy link
Author

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.

src/jsx/index.ts Show resolved Hide resolved
src/jsx/tsconfig.json Show resolved Hide resolved
src/jsx/index.ts Outdated Show resolved Hide resolved
src/jsx/console.ts Show resolved Hide resolved
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",
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
"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.

@vespakoen
Copy link
Author

I just pushed changes that runs the build command serially and starts a typescript server just for showing the typescript errors (not for actually compiling stuff)

I also fixed most .ts errors (I have only one left that comes from cep-interface):

../../node_modules/cep-interface/lib/cs-interface.d.ts:1:22 - error TS6053: File '/Users/koen/Projects/adobe-extension-tools/parcel-plugin-cep-starter/node_modules/cep-interface/src/window.d.ts' not found.

1 /// <reference path="../src/window.d.ts" />

And updated the parcel-plugin-cep dependency to version 1.2.0

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