prismicio / slice-machine

A series of tools for developing and deploying website sections with Prismic
https://prismic.io/docs
Apache License 2.0
287 stars 53 forks source link

Guide on how to contribute and get started #277

Closed greatwitenorth closed 1 year ago

greatwitenorth commented 2 years ago

Is your feature request related to a problem? Please describe.

I would like to start contributing to the project (specifically the Gatsby work). I've cloned the repository and done yarn and yarn run build but I'm met with a lot of errors and failed tests (on master branch), the first being:

 FAIL  packages/core/__tests__/src/utils/cookie.test.ts
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/nickv/Projects/slice-machine/packages/core/__tests__/src/utils/cookie.test.ts:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { describe, expect, test, afterEach } from "@jest/globals";
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1258:14)

Not too sure where to go from here.

Describe the solution you'd like

It'd be great to have some documentation about how to get up and running for development. Instructions on how to develop locally and use the locally built slice machine in your projects would be great.

ReeceM commented 2 years ago

Hey @greatwitenorth

not sure if you have tried but from my experience a lot of the newer features are usually on different branches and not the master/main branch.

For the SMUI part, that worked doing that.

greatwitenorth commented 2 years ago

@ReeceM Thanks for the reply. I did try the aa/gatsby branch, but still saw the same error messages. I'm not sure if it's something to do with my local setup. Seems like Jest isn't able to process the typescript files maybe? I don't have a ton of experience with javascript package development. So I was just hoping there would be a step-by-step to get you started with building the project (without errors).

MarcMcIntosh commented 2 years ago

hi @greatwitenorth it looks like you're trying to build the core?

setup and install everything with (we version our upstream branches)

git clone https://github.com/prismicio/slice-machine -b v0.2.0
cd slice-machine
npm install

From there it really depends on what you want to do, if you want to build the project but usually the core will need to be built first. so cd packages/core && npm run build