I created services/store.js with default export, then I added "@service store;" in route. Right at that line the following error occurs:
TypeError: Cannot read properties of undefined (reading 'default')
at Module.default (webpack://tkl/./services/store.js?:3:107)
at Resolver._extractDefaultExport (webpack://tkl/../rewritten-packages/ember-resolver.4afe6404/node_modules/ember-resolver/index.js?:389:25)
at Resolver.resolveOther (webpack://tkl/../rewritten-packages/ember-resolver.4afe6404/node_modules/ember-resolver/index.js?:150:32)
at Resolver.resolve (webpack://tkl/../rewritten-packages/ember-resolver.4afe6404/node_modules/ember-resolver/index.js?:171:23)
at resolve (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:725:1)
at Registry.resolve (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:506:1)
at Registry.resolve (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:508:1)
at has (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:738:1)
at Registry.has (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:588:1)
at Registry.proto.validateInjections (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:710:1)
at InternalFactoryManager.create (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:369:1)
at Proxy.create (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:204:1)
at instantiateFactory (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:276:1)
at lookup (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:223:1)
at Container.lookup (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/container/index.js:121:1)
at ApplicationInstance.lookup (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/-internals/runtime/lib/mixins/container_proxy.js:19:1)
at PrivateRouter.getRoute (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/routing/router.js:183:1)
at UnresolvedRouteInfoByParam.fetchRoute (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/router_js.js:714:1)
at UnresolvedRouteInfoByParam.get route [as route] (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/router_js.js:648:1)
at URLTransitionIntent.applyToState (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/router_js.js:1151:1)
at PrivateRouter.getTransitionByIntent (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/router_js.js:1276:1)
at PrivateRouter.transitionByIntent (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/router_js.js:1239:1)
at PrivateRouter.doTransition (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/router_js.js:1357:1)
at PrivateRouter.handleURL (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/router_js.js:1748:1)
at Router._doURLTransition (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/routing/router.js:474:1)
at Router.handleURL (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/routing/router.js:470:1)
at ApplicationInstance.visit (/var/folders/1w/g50r82q15y31dhfvgqjznd300000gn/T/broccoli-7267293LUmMz80Ulj/out-752-packager_runner_embroider_webpack/assets/@ember/application/instance.js:215:1)
at EmberApp._visit (/Users/boris/Projects/tkl/node_modules/fastboot/src/ember-app.js:269:20)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at EmberApp.visit (/Users/boris/Projects/tkl/node_modules/fastboot/src/ember-app.js:329:7)
at FastBoot.visit (/Users/boris/Projects/tkl/node_modules/fastboot/src/index.js:86:18)
at /Users/boris/Projects/tkl/node_modules/fastboot-express-middleware/src/index.js:33:20
I tried to inject store using getter or somehow debug/google the problem. However, it leads to nowhere. Has someone any ideas about that?
Here's the code that generates the error:
Route:
// app/routes/blogposts.ts
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default class BlogpostsRoute extends Route {
@service store;
// no matter what is inside this hook and whether it exists at all, no impact on the error
model(params) {
}
}
Adapter:
// app/adapters/blogpost.ts
import RESTAdapter from '@ember-data/adapter/rest';
export default class BlogpostAdapter extends RESTAdapter {
host = 'http://localhost:3333';
}
declare module 'ember-data/types/registries/adapter' {
export default interface AdapterRegistry {
blogpost: BlogpostAdapter;
}
}
Serializer:
// app/serializers/blogpost.ts
import RESTSerializer from '@ember-data/serializer/rest';
export default class BlogpostSerializer extends RESTSerializer {}
declare module 'ember-data/types/registries/serializer' {
export default interface SerializerRegistry {
blogpost: BlogpostSerializer;
}
}
Service:
// app/services/service.js
export { default } from 'ember-data/store';
The problem is solved. The solution is Fastboot incompatible with modern state of the ecosystem
I applied changes from branch "fastboot-broken" which is not merged at this moment of writing this post. Once I did, the problem disappeared.