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

run-migration is broken after ESM migration #95

Closed
privetkuku opened this issue May 13, 2024 · 5 comments · Fixed by #116
Closed

run-migration is broken after ESM migration #95

privetkuku opened this issue May 13, 2024 · 5 comments · Fixed by #116
Assignees
Labels
bug Something isn't working p4-important [Priority] Violate documented behavior or significantly improve performance (priority)

Comments

@privetkuku
Copy link

Current behavior:

  • Generate migration. It will produce .js file with export default ESM statement
  • Run run-migration. Error will be thrown, because Node.js didn't expect to see ESM export in .js file

Expected behavior:

  • Migration is executed without error

Steps to reproduce:
Steps are described in Current behaviour section.

Related code:
Code that broke the functionality - 891af62#diff-2c9538c486ae6103ef79ac65657bf841191ae869f4992158328e6739c28e463c

Other information:
To fix the issue, you need to generate .mjs files, not .js.
Current "fix" for me is to use --experimental-detect-module flag, but that's not safe.

@privetkuku privetkuku added the bug Something isn't working label May 13, 2024
@OFranke
Copy link

OFranke commented May 21, 2024

I am running into the same issue, but your "fix" using --experimental-detect-module doesn't work for me. It just tells me error: unknown option '--experimental-detect-module'. Which CLI version did you install @privetkuku ?

@privetkuku
Copy link
Author

privetkuku commented May 22, 2024

@OFranke, I have 3.30.0 version installed. '--experimental-detect-module' was introduced in Node 21.1.0 and you need to pass it to the Node itself, not Storyblok.

I use pnpm, for me it looks like this: NODE_OPTIONS='--experimental-detect-module' pnpm storyblok ....

Hope that helps.

@privetkuku
Copy link
Author

@christianzoppi, can you please into it?

@alvarosabu alvarosabu added the p4-important [Priority] Violate documented behavior or significantly improve performance (priority) label Sep 12, 2024
@alvarosabu alvarosabu self-assigned this Sep 12, 2024
@alvarosabu
Copy link
Contributor

alvarosabu commented Sep 12, 2024

Hey there @privetkuku @OFranke I'm currently checking out this issue.

If I understand correctly, the problem comes when trying to run previously generated CJS versions of the migrations in the newest versions right? I guess it also depends on the Node version of the project if it's using >18 or not 🤔.

@alvarosabu alvarosabu linked a pull request Sep 13, 2024 that will close this issue
5 tasks
@privetkuku
Copy link
Author

Hello @alvarosabu, thanks for looking into it!
After version bump back then, even newly created migrations were not able to run due to the described reasons in Current behavior section.
I see your fix #116, I think it should do the job🦉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p4-important [Priority] Violate documented behavior or significantly improve performance (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants