Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

setup rollup & cjs build #15

Closed
wants to merge 1 commit into from
Closed

Conversation

Drapegnik
Copy link
Contributor

@Drapegnik
Copy link
Contributor Author

@matthewp

@wuarmin
Copy link

wuarmin commented Mar 30, 2021

This PR would fix an issue with jest test runner. Wdyt @matthewp ? Can we merge it?

@matthewp
Copy link
Owner

Sorry, my head has been in other stuff lately, I don't get what this solves? What is it about this code that jest has an issue with?

@wuarmin
Copy link

wuarmin commented Mar 31, 2021

Obviously we need a build strategy. @Drapegnik adds build analogous to robot-hooks in this PR.

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:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/en/ecmascript-modules for how to enable it.
     • 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:

    /home/user/code/best-app-ever/node_modules/react-robot/machine.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { useEffect, useState } from 'react';
                                                                                                    ^

    SyntaxError: Unexpected token {

      1 | import { useEffect } from "react";
      2 | import { gql, useMutation } from "@apollo/client";
    > 3 | import { useMachine } from "react-robot";
        | ^
      4 |
      5 | import useQueryIssues from "./use-query-issues";
      6 | import requestIssueMachine from "../state-machines/request-issue-machine";

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
      at Object.<anonymous> (src/custom-hooks/use-request-credit-machine.js:3:1)

@matthewp
Copy link
Owner

matthewp commented Feb 2, 2023

Sorry for not following up on this. There is now a build, this package is in the main repository if you'd like to see some other change going forward. https://github.com/matthewp/robot/tree/main/packages/react-robot

@matthewp matthewp closed this Feb 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problem with es modules with next.js
3 participants