Repository navigation
Top-level ESM support for Electron applications #659
Copy link
Copy link
Open
Labels
bugBug reports or bug fixesBug reports or bug fixesdependenciesIssues or updates to dependency filesIssues or updates to dependency filesfeatureFeature requests or improvementsFeature requests or improvements
Description
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:
- Open a terminal/command-line
- Navigate to the root directory of the Synectic source code
- Run any test that exercises a React component that uses
sindresorhus/dot-prop(e.g.yarn test src/components/Stack) - 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:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugBug reports or bug fixesBug reports or bug fixesdependenciesIssues or updates to dependency filesIssues or updates to dependency filesfeatureFeature requests or improvementsFeature requests or improvements
Activity
Downgrade to dot-prop@6.0.1 to mitigate ESM requirement #659
[-]Testing components with sindresorhus/dot-prop requires ESM support[/-][+]ESM support required in order to use ESM dependencies[/+]v2.0.0 (#807)
[-]ESM support required in order to use ESM dependencies[/-][+]Top-level ESM support in Electron and Synectic[/+][-]Top-level ESM support in Electron and Synectic[/-][+]Top-level ESM support for Electron applications[/+]nelsonni commentedon Oct 20, 2023
Per Electron Timelines, Electron 28.0.0 stable is expected to be released on 2023-Dec-5. There is a ES Modules (ESM) in Electron tutorial describing the steps required in order to take advantage of ESM once 28.0.0 is generally available.