Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with modern tooling without polyfilling nodeisms #45

Open
MichalBryxi opened this issue Dec 17, 2024 · 4 comments
Open
Assignees

Comments

@MichalBryxi
Copy link

MichalBryxi commented Dec 17, 2024

Not sure which side is the problematic one (Ember / Embroider / statelyai/inspect / ?), but to document this:

// package.json
    ...
  "devDependencies": {
    "ember-statechart-component": "^7.1.0",
    "@statelyai/inspect": "^0.4.0",
    "xstate": "^5.19.0"
  }
    ...
// machine.ts

import { setup } from 'xstate';
import { createBrowserInspector } from '@statelyai/inspect';

const { inspect } = createBrowserInspector();

const machine = setup({ ... }).createMachine({ ... });

Produces following errors:

router.js:1323 Error while processing route: add-a-building ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ../../.pnpm/@[email protected][email protected][email protected]/node_modules/@statelyai/inspect/dist/index.js Error: ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ../../.pnpm/@[email protected][email protected][email protected]/node_modules/@statelyai/inspect/dist/index.js

and

Uncaught Error: ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ../../.pnpm/@[email protected][email protected][email protected]/node_modules/@statelyai/inspect/dist/index.js
    at Object.set [as exports] 

Environment:

pnpm exec ember version
ember-cli: 6.0.1
node: 20.18.0
os: darwin arm64

We're talking embroider enabled build based on webpack. I suspect that might play a role:

    "@embroider/compat": "^3.7.0",
    "@embroider/core": "^3.4.19",
    "@embroider/webpack": "^4.0.8",
@MichalBryxi
Copy link
Author

Kickstarted a conversation on EmberJS discord

@NullVoxPopuli
Copy link

NullVoxPopuli commented Dec 17, 2024

To me, it looks like the package is built incorrectly.

https://www.npmjs.com/package/@statelyai/inspect?activeTab=code
Screenshot_20241217-081013

Module isn't a thing in esm, so it would errors ... Or it requires special webpack or vite configuration to polyfill module.

Ember won't polyfill this sort of stuff because doing so would perpetuate bad patterns in the ecosystem.

It's probably just an oversight. This sort of compilation was common in the old days.

But the inspect package needs to use package.json#exports and provide per-format compilation (the rest of xstate already makes heavy and good use of package.json#exports)

@NullVoxPopuli
Copy link

@MichalBryxi i'd rename this issue to 'not compatible with modern tooling without polyfilling nodeisms' (webpack 5, vite)

@MichalBryxi MichalBryxi changed the title ESM issue with EmberJS Not compatible with modern tooling without polyfilling nodeisms Dec 17, 2024
@davidkpiano
Copy link
Member

If you know of a potential fix, I'd appreciate a PR for it 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants