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

FastBoot support #112

Closed
josemarluedke opened this issue Mar 30, 2019 · 8 comments
Closed

FastBoot support #112

josemarluedke opened this issue Mar 30, 2019 · 8 comments

Comments

@josemarluedke
Copy link
Collaborator

josemarluedke commented Mar 30, 2019

I was trying out to see if Embroider did work with fastboot, but I had some issues.

Here is the error I'm getting:

Error: Couldn't find /var/folders/67/6jb5flcd6d30lkgvj0_92c_m0000gn/T/broccoli-1293OJSXVVXmzNOx/out-170-packager_runner_embroider_webpack/package.json. You may need to update your version of ember-cli-fastboot.
    at EmberApp.readPackageJSON (/Users/josemarluedke/code/tmp/my-embroider-test/node_modules/fastboot/src/ember-app.js:350:13)
    at new EmberApp (/Users/josemarluedke/code/tmp/my-embroider-test/node_modules/fastboot/src/ember-app.js:34:23)
    at FastBoot._buildEmberApp (/Users/josemarluedke/code/tmp/my-embroider-test/node_modules/fastboot/src/index.js:114:17)
    at new FastBoot (/Users/josemarluedke/code/tmp/my-embroider-test/node_modules/fastboot/src/index.js:52:10)
    at app.use (/Users/josemarluedke/code/tmp/my-embroider-test/node_modules/ember-cli-fastboot/index.js:319:29)
    at Layer.handle [as handle_request] (/Users/josemarluedke/code/tmp/my-embroider-test/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/josemarluedke/code/tmp/my-embroider-test/node_modules/express/lib/router/index.js:317:13)
    at /Users/josemarluedke/code/tmp/my-embroider-test/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/josemarluedke/code/tmp/my-embroider-test/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/josemarluedke/code/tmp/my-embroider-test/node_modules/express/lib/router/index.js:275:10)

Repo: https://github.com/josemarluedke/my-embroider-test/tree/fastboot

@ef4
Copy link
Contributor

ef4 commented Apr 26, 2019

I think this is because embroider isn't running postprocessTree hooks. That is how ember-cli-fastboot adds package.json to dist.

There are various flavors of postprocessTree. In this case the one that matters is "all". The "all" hook is somewhat problematic. Most of the things people do in that hook are actively harmful under embroider (for example, trying to fingerprint assets and rewrite their URLs will break lazy loading. Fingerprinting is a concern of the stage3 packager, not something people should try to impose upon it from outside).

@rwjblue, you asked me about what fastboot can do to make compatibility easier. One idea is, can ember-cli-fastboot emit all the config files it needs via the public tree instead of using postprocessTree? There's not really any postprocessing needed, it's just merging in files.

@tmquinn
Copy link
Contributor

tmquinn commented Oct 30, 2019

@ef4 I am looking at adding pre/postprocessTree for all types except for "all". Just wanted to check with you first as to whether this is something you really want.

@ef4
Copy link
Contributor

ef4 commented Oct 31, 2019

Yes, that's fine. Mostly they would belong in v1-addon.ts. And some already run by virtue of us calling methods that call them.

@tmquinn
Copy link
Contributor

tmquinn commented Oct 31, 2019

So I have been looking for that, but I've run a few tests and I never see postprocessTree being called from Embroider ever. Can you point out where they are being called?

@ef4
Copy link
Contributor

ef4 commented Oct 31, 2019

If you put a breakpoint here you can see which ones are running.

Pre and post for js and template definitely run, and you can see their callstacks to see why.

Pre and post for css also run for addons that have styles and don't have a customized treeForAddonStyles. The customized case is apparently still a todo in the embroider source.

@tmquinn
Copy link
Contributor

tmquinn commented Nov 1, 2019

Aaahhh... I admit I have an incomplete understanding of when this hook works, but this clears it up some.

@stefanpenner wanted a warning if there was a customized pre/postprocessTree hook of type all. Is it accurate to say that pre/postprocessTree('all') is only called on an App and never an Addon? Would it be sufficient to simply sniff the App for a customized `pre/processTree hook and throw a warning if it exists?

@ef4
Copy link
Contributor

ef4 commented Nov 1, 2019

Is it accurate to say that pre/postprocessTree('all') is only called on an App and never an Addon?

No. It's (entirely?) addons that do it. They don't do it arbitrarily deep down the dependency graph, but all your direct addons can do postprocessTree('all')`.

The best place for that warning is probably here. It can be just like the one for treeFor.

@NullVoxPopuli
Copy link
Collaborator

The current version of fastboot is tested in the embroider test suite 🎉

For newer issues, lets open new issues 🥳 thanks all!!

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

No branches or pull requests

4 participants