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

Fix .default is not a function errors #18188

Merged
merged 5 commits into from Apr 14, 2023

Conversation

azrikahar
Copy link
Contributor

@azrikahar azrikahar commented Apr 14, 2023

When building with the extensions-sdk using a generated template (using a hook template for example), an error such as the following will occur:

The image shows it for replace.default, but the same issue exists for commonjs, json, terser.

The fix seems to work after removing all the .default added in https://github.com/directus/directus/pull/18014/files#diff-a5033ca89b34aa9443a9a7d79f0a134c6562795edeb3e5a87cbaab9c01655c1b, but there are still typescript errors when actually building the extensions-sdk, hence the addition of // @ts-ignore comments, which aren't ideal.

I also wonder if it's possible to resolve this by upgrading @rollup/plugin-commonjs, but it was recently intentionally downgraded in #17539.

@azrikahar azrikahar marked this pull request as ready for review April 14, 2023 14:54
@azrikahar azrikahar requested review from a team, nickrum, connorwinston and Nitwel and removed request for a team April 14, 2023 14:55
@azrikahar
Copy link
Contributor Author

Opting to use the same workaround used in the API for now:

// Workaround for https://github.com/rollup/plugins/issues/1329
const virtual = virtualDefault as unknown as typeof virtualDefault.default;
const alias = aliasDefault as unknown as typeof aliasDefault.default;
const nodeResolve = nodeResolveDefault as unknown as typeof nodeResolveDefault.default;

@rijkvanzanten rijkvanzanten merged commit f016e22 into main Apr 14, 2023
6 checks passed
@rijkvanzanten rijkvanzanten deleted the fix/extensions-sdk-build-command branch April 14, 2023 16:43
hanneskuettner pushed a commit to hanneskuettner/directus that referenced this pull request Apr 18, 2023
* fix .default is not a function errors

* use workaround

* use workaround for the other plugins as well

* upgrade rollup plugin commonjs and terser

---------

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
@rijkvanzanten rijkvanzanten added this to the Next Release milestone Apr 20, 2023
meditadvisors pushed a commit to ciso360ai/directus-mod that referenced this pull request May 13, 2023
* fix .default is not a function errors

* use workaround

* use workaround for the other plugins as well

* upgrade rollup plugin commonjs and terser

---------

Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants