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

feat(gatsby): Slices API #36489

Merged
merged 99 commits into from Oct 7, 2022
Merged

feat(gatsby): Slices API #36489

merged 99 commits into from Oct 7, 2022

Conversation

imjoshin
Copy link
Contributor

@imjoshin imjoshin commented Aug 29, 2022

Description

This implements #36339 minus the "Using the Filesystem"

Documentation

Documentation for this feature is part of V5 docs

Related Issues

[sc-55262]

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Aug 29, 2022
@imjoshin imjoshin added topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Aug 29, 2022
packages/gatsby-cli/src/structured-errors/error-map.ts Outdated Show resolved Hide resolved
packages/gatsby-cli/src/structured-errors/error-map.ts Outdated Show resolved Hide resolved
message = `Slice "${sliceName}" was passed props ${componentHint}that are not serializable (${errors}).`
} else {
// we can't really grab any extra info outside of the browser, so just print what we can
message = `${name}: Slice "${sliceName}" was passed props that are not serializable (${errors}). Use \`gatsby develop\` to see more information.`
Copy link
Contributor

Choose a reason for hiding this comment

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

Where/How in gatsby develop would they see more info? Terminal? Browser console? Error overlay?

Copy link
Contributor

Choose a reason for hiding this comment

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

causing error:
image

it shows in overlay, however code frame, code location is not right currently
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something must have changed recently or we added a level of depth in our tree.

It used to render to the first line of the file containing the error-ing Slice. Should be somewhere in here:

// remove the first line of the stack trace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Contributor

@pieh pieh Oct 7, 2022

Choose a reason for hiding this comment

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

This proves to be difficult to resolve in confident way. The component stack I'm getting is missing file/line number location for a lot of frames (including the component that uses the slice):

    at Slice (webpack-internal:///./.cache/slice.js:32:24)
    at main
    at IndexPage
    at PageRenderer (webpack-internal:///./.cache/page-renderer.js:21:84)
    at PageQueryStore (webpack-internal:///./.cache/query-result-store.js:40:30)
    at RouteHandler
    at div
    at oe (webpack-internal:///./node_modules/@gatsbyjs/reach-router/dist/index.modern.mjs:38:9978)
    at re (webpack-internal:///./node_modules/@gatsbyjs/reach-router/dist/index.modern.mjs:38:9765)
    at ie (webpack-internal:///./node_modules/@gatsbyjs/reach-router/dist/index.modern.mjs:38:11249)
    at se (webpack-internal:///./node_modules/@gatsbyjs/reach-router/dist/index.modern.mjs:38:11123)
    at ScrollHandler (webpack-internal:///./node_modules/gatsby-react-router-scroll/scroll-handler.js:36:35)
    at RouteUpdates (webpack-internal:///./.cache/navigation.js:289:32)
    at EnsureResources (webpack-internal:///./.cache/ensure-resources.js:22:30)
    at LocationHandler (webpack-internal:///./.cache/root.js:64:29)
    at eval (webpack-internal:///./node_modules/@gatsbyjs/reach-router/dist/index.modern.mjs:38:8351)
    at H (webpack-internal:///./node_modules/@gatsbyjs/reach-router/dist/index.modern.mjs:38:7249)
    at G (webpack-internal:///./node_modules/@gatsbyjs/reach-router/dist/index.modern.mjs:38:7551)
    at WithErrorBoundary()
    at Q (webpack-internal:///./node_modules/@gatsbyjs/reach-router/dist/index.modern.mjs:38:9142)
    at Root
    at StaticQueryStore (webpack-internal:///./.cache/query-result-store.js:159:32)
    at SliceDataStore (webpack-internal:///./.cache/query-result-store.js:215:32)
    at ErrorBoundary (webpack-internal:///./.cache/fast-refresh-overlay/components/error-boundary.js:24:35)
    at DevOverlay (webpack-internal:///./.cache/fast-refresh-overlay/index.js:124:5)
    at RootWrappedWithOverlayAndProvider
    at App (webpack-internal:///./.cache/app.js:184:80)

During debugging I found information about code location in fibers data, but that data isn't actually used for produced component stack (_debugSource field points to place where <Slice> is actually used in my test):

image

this might be avenue to get correct location in overlay, but I don't want to keep this PR hostage for this

packages/gatsby/cache-dir/slice/context.js Show resolved Hide resolved
packages/gatsby/cache-dir/static-entry.js Outdated Show resolved Hide resolved
packages/gatsby/src/utils/slices.ts Outdated Show resolved Hide resolved
packages/gatsby/src/utils/webpack.config.js Outdated Show resolved Hide resolved
@pieh pieh force-pushed the slices-api branch 3 times, most recently from 3055b95 to 56f8069 Compare October 6, 2022 15:42
@pieh pieh marked this pull request as ready for review October 7, 2022 07:57
@LekoArts LekoArts changed the title feat(gatsby): Slices API WIP feat(gatsby): Slices API Oct 7, 2022
@LekoArts LekoArts merged commit 6660144 into master Oct 7, 2022
@LekoArts LekoArts deleted the slices-api branch October 7, 2022 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants