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

BUG: Async Neos Ui Plugins: regeneratorRuntime is not defined #3470

Closed
pKallert opened this issue Apr 29, 2023 · 3 comments
Closed

BUG: Async Neos Ui Plugins: regeneratorRuntime is not defined #3470

pKallert opened this issue Apr 29, 2023 · 3 comments
Labels
8.2 8.3 Bug Label to mark the change as bugfix Extensibility

Comments

@pKallert
Copy link
Contributor

pKallert commented Apr 29, 2023

Description

When using neos expensibility to develop a plugin, using async throws errors:
[Description of the bug or feature]

Bildschirmfoto 2023-04-21 um 14 53 04

Steps to Reproduce

  1. Use Neos extensibility with the following dependencies:
devDependencies": {
        "@neos-project/build-essentials": "^8.2.0",
        "@neos-project/neos-ui-extensibility": "^8.2.0"
    },
  1. Use async (for example for getting data from a dataSource):
async function getData(globalRegistry) {
	const dataLoadersRegistry = globalRegistry
		.get('dataLoaders')
		.get('DataSources');
	return dataLoadersRegistry.resolveValue({
		contextNodePath: null,
		dataSourceIdentifier: 'test-identifier'
	});
}

Expected behavior

I should be able to use async and Promises with neos-ui-extensibility without adding additional packages. It should not throw additional errors.

Actual behavior

I need to add an additional dependency "regenerator runtime" for no error to show up
Package: https://www.npmjs.com/package/regenerator-runtime

Affected Versions

Neos-ui-extensibility: 8.2

UI: 8.2

@mhsdesign
Copy link
Member

Alternatively i can recommend using the new esbuild api: https://github.com/neos/neos-ui/tree/8.3/packages/neos-ui-extensibility

@Sebobo
Copy link
Member

Sebobo commented Apr 29, 2023

Hm shouldn't this be solved by a correct browserslist config?
The regenerator runtime is only formlos browser targets if I remember correctly.

@mhsdesign mhsdesign changed the title BUG: Async does not work by default with Neos extensibility BUG: Async Neos Ui Plugins: regeneratorRuntime is not defined Aug 30, 2023
@mhsdesign
Copy link
Member

mhsdesign commented Aug 30, 2023

I did also notice this problem in one of my plugins - but in relation with generators yield instead of like you with async await?

This is a regression from the EsBuild change in 8.2 as we removed the polyfills (polyfill.js) and thus also the regenerator runtime polyfill (import 'regenerator-runtime/runtime';). We removed the polyfills as we were from then on targeting only modern Browsers (at least ES2020) but i didnt think of the fact that build plugins might transpile down to an older es version and thus require regeneratorRuntime.

Additionally this problem is obscured because other Neos Ui Plugins might now already ship the global regeneratorRuntime and then other plugins can profit from this invisible dependency and work. But as soon as no other plugin is installed anymore or the settings loading order changes (due to a deployment on another unix system where settings might be picked up in a different order) your plugin might stop working.

I think as seb said, plugins using the modern webpack extensibility (v8.2 or 8.3) should simply at no time build plugins which require the legacy regeneratorRuntime. This should be the default - and its currently not.


I just tested it, it seems removing the babel-plugin-transform-regenerator from our webpack config works and leaves our code alone. yield stays a js-generator and will not be rewritten to a state machine which depends on regeneratorRuntime.

[require.resolve('babel-plugin-transform-regenerator'), {async: false, asyncGenerators: false}]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.2 8.3 Bug Label to mark the change as bugfix Extensibility
Projects
None yet
Development

No branches or pull requests

4 participants