question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create Slice in SliceMachine UI doesn't behave the same as the CLI create-slice command

See original GitHub issue

Version

  • Prismic CLI version (know it by running prismic --version): prismic-cli/4.0.1-alpha.10
  • slice-machine-ui: ^0.1.0-alpha.5

Reproduction

  • run yarn slicemachine to open the builder

  • create a new slice called BuilderSlice

  • It should save it to the file system

  • Then open the terminal and run prismic sm --create-slice

  • Leave the default slice folder slices

  • Set the name as CliSlice

  • Press return

This should have created two new slices and the related .storybook/assets/ entries.

What is expected?

The expected behavior is that it should create the slices and then populate the @/slices/index.js file with the new slices as:

export { default as BuilderSlice } from './BuilderSlice'
export { default as CliSlice } from './CliSlice'

What is actually happening?

The slices created via the builder do not update the index.js file under the slices library that has been defined, while the cli command still does that.

Instead what is in the file is:

export { default as CliSlice } from './CliSlice'

This is a problem as then the slices are called in the sm-resolver.js file as:

import * as Slices from './slices'
const __allSlices = {  ...Slices, }

This means it will get some, but not all.

Any additional information

Package.json

{
  "dependencies": {
    "essential-slices": "^1.0.4",
    "next": "10.2.0",
    "next-slicezone": "^0.0.15",
    "next-transpile-modules": "^7.0.0",
    "prismic-javascript": "^3.0.2",
    "prismic-reactjs": "^1.3.3",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "theme-ui": "^0.8.4"
  },
  "devDependencies": {
    "@storybook/react": "^6.2.8",
    "babel-loader": "^8.2.2",
    "babel-plugin-react-require": "^3.1.3",
    "slice-machine-ui": "^0.1.0-alpha.5"
  }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ReeceMcommented, Jul 6, 2021

appears to be fixed in the alpha releases of both the cli and SM-UI.

Also was going to add the other issue of the two commands producing different storybook results but https://github.com/prismicio/prismic-cli/pull/101 fixes that it appears 👍

1reaction
hypervillaincommented, Jun 16, 2021

The slices/index.js file will be updated after each slice update in the upcoming builder

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create-slice behaves differently since prismic-cli 4.2
Since I upgraded to the prismic-cli v4.2 the sm --create-slice behaves differently in the sense: it throws a conflict with slices\index.js ...
Read more >
Step-by-step guide on how to create your first slices with Slice ...
Step-by-step guide on how to create your first slices with Slice Machine for the #SliceContestMore info about the SliceContest: ...
Read more >
Build Flexible CMS Layouts with Slice Machine (with Lucie ...
demo: https://prismic- slice-machine.netlify.app/* repo: https://github.com/learnwithjason/prismic- slice -machineLinks: - https://prismic.io/- ...
Read more >
Build Flexible CMS Layouts with Slice Machine
Lucie: Add to the CLI for launching another command to have some other magic. So, this time, we are gonna launch Slice Machine...
Read more >
slice-machine-ui - npm
Create slices locally;; Manage your custom types;; Storybook integrated workflow. Install. npx @slicemachine/init ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found