Skip to content

Top-level ESM support for Electron applications #659

@nelsonni

Description

@nelsonni

Describe the bug
Running Jest tests that make reference to the sindresorhus/dot-prop dependency causes the following error message:

❯ yarn test src/components/Stack
yarn run v1.22.17
$ jest src/components/Stack
 FAIL  src/components/Stack/Stack.spec.tsx
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
     • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • 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/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    /Users/nelsonni/Workspace/synectic/node_modules/dot-prop/index.js:173
    export function getProperty(object, path, value) {
    ^^^^^^

    SyntaxError: Unexpected token 'export'

       5 | import * as ini from 'ini';
       6 | import parse from 'parse-git-config';
    >  7 | import { getProperty, setProperty, hasProperty, deleteProperty } from 'dot-prop';
         | ^
       8 | import getGitConfigPath from 'git-config-path';
       9 | import type { Repository, GitStatus } from '../types';
      10 | import * as io from './io';

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)
      at Object.<anonymous> (src/containers/git-porcelain.ts:7:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        2.159 s
Ran all test suites matching /src\/components\/Stack/i.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

This error occurs because sindresorhus/dot-prop v7.0.0 converts to a pure ESM format, which requires similar updates to all downstream projects (including Synectic).

To Reproduce
Steps to reproduce the behavior:

  1. Open a terminal/command-line
  2. Navigate to the root directory of the Synectic source code
  3. Run any test that exercises a React component that uses sindresorhus/dot-prop (e.g. yarn test src/components/Stack)
  4. See error

Expected behavior
Test suites should run and provide results based on the tests.

Screenshots
N/A

Versions (please complete the following information):

  • OS: MacOS
  • Synectic Version: 1.4.1

Additional context
Relevant issues/PR being tracked for resolution:

Metadata

Metadata

Assignees

Labels

bugBug reports or bug fixesdependenciesIssues or updates to dependency filesfeatureFeature requests or improvements

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions