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

hooks.js warning in console when building #990

Closed
pikeas opened this issue Apr 13, 2021 · 4 comments · Fixed by #1003
Closed

hooks.js warning in console when building #990

pikeas opened this issue Apr 13, 2021 · 4 comments · Fixed by #1003
Labels
bug Something isn't working

Comments

@pikeas
Copy link

pikeas commented Apr 13, 2021

Describe the bug

$ npm run build --verbose
...
vite v2.1.5 building SSR bundle for production...en Completed in 3ms
'getContext' is not exported by '.svelte/build/hooks.js'leted in 3ms
'getSession' is not exported by '.svelte/build/hooks.js'
'handle' is not exported by '.svelte/build/hooks.js'
✓ 14 modules transformed.
.svelte/output/server/app.js   72.24kb

Happens with the static and node adapters.

Expected behavior
No errors.

Information about your SvelteKit Installation:
All libraries are up-to-date (kit @ .73).

Severity
Annoying and may be indicative of a bug in sveltekit, nothing seems to actually be broken.

Additional context
I'm working to reproduce from a fresh repro. Clues:

// .svelte/build/app.js
import * as user_hooks from "./hooks.js";
...
const hooks = {
	getContext: user_hooks.getContext || (() => ({})),
	getSession: user_hooks.getSession || (() => ({})),
	handle: user_hooks.handle || (({ request, render }) => render(request))
};
// .svelte/output/server/app.js
...
const context = await options.hooks.getContext(incoming) || {};
  • .svelte/build/hooks.js exists and is empty.
  • There is no usage of context in the project.
  • I've blown away .svelte, build, functions, and node_modules, which didn't help.
  • The vite output is interleaved - two different processes are fighting to write to stderr simultaneously. This may be an unrelated issue.
@pikeas
Copy link
Author

pikeas commented Apr 13, 2021

Reproduction:

$ npm init svelte@next
# Typescript, CSS, yes, yes
$ npm install
$ npm run build
> foo@0.0.1 build
> svelte-kit build

vite v2.1.5 building for production...
✓ 18 modules transformed.
.svelte/output/client/_app/manifest.json                              1.28kb
.svelte/output/client/_app/pages/$layout.svelte-542a9f8f.js           0.49kb / brotli: 0.29kb
.svelte/output/client/_app/error.svelte-a4e5c48e.js                   1.11kb / brotli: 0.55kb
.svelte/output/client/_app/assets/start-a8cd1609.css                  0.16kb / brotli: 0.10kb
.svelte/output/client/_app/pages/index.svelte-3c4e948d.js             1.71kb / brotli: 0.75kb
.svelte/output/client/_app/assets/pages/$layout.svelte-164b8506.css   0.13kb / brotli: 0.11kb
.svelte/output/client/_app/assets/pages/index.svelte-107d1063.css     0.71kb / brotli: 0.26kb
.svelte/output/client/_app/chunks/vendor-43f860ae.js                  5.22kb / brotli: 2.03kb
.svelte/output/client/_app/start-42c46b07.js                          16.22kb / brotli: 5.13kb
vite v2.1.5 building SSR bundle for production...
transforming (5) .svelte/build/generated/root.svelte'getContext' is not exported by '.svelte/build/hooks.js'
'getSession' is not exported by '.svelte/build/hooks.js'
'handle' is not exported by '.svelte/build/hooks.js'
✓ 16 modules transformed.
.svelte/output/server/app.js   74.78kb

@benmccann benmccann changed the title Hooks.js error hooks.js warning in console when building Apr 13, 2021
@frederikhors
Copy link
Contributor

It happens from .73 upwards.

@benmccann
Copy link
Member

From Rich:
It looks like get_hooks wasn't unnecessary indirection
vite/rollup balks at the hooks.getContext reference if the user doesn't define it. by passing it into the function we get access to the module record without triggering rollup's persnickitiness

@Conduitry
Copy link
Member

The 'unnecessary indirection' refers to the simplification I made in #959 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants