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

feat: Use dynamic import for external JS #26522

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

Nerivec
Copy link
Collaborator

@Nerivec Nerivec commented Feb 26, 2025

  • Replace node:vm logic with dynamic importing
  • Allow .js, .cjs and .mjs code
  • [live-reload] Version file naming on MQTT save when file already exists (also allows to bypass node module caching)
  • Update typing
  • Add MJS-specific tests
  • Update test sample converters to use importing for better representation
  • Skip and relocate invalid external JS on Z2M start

TODO:

@Nerivec Nerivec force-pushed the externaljs-dynamic-import branch 2 times, most recently from 22e99d2 to 54083d7 Compare March 1, 2025 22:46
@Nerivec Nerivec force-pushed the externaljs-dynamic-import branch 2 times, most recently from 73a09f0 to 250649f Compare March 5, 2025 02:49
@Nerivec Nerivec force-pushed the externaljs-dynamic-import branch 5 times, most recently from 849dcb7 to 373d1a5 Compare March 13, 2025 23:10
@Nerivec Nerivec force-pushed the externaljs-dynamic-import branch from 373d1a5 to f4775f5 Compare March 15, 2025 14:13
Nerivec added a commit to Nerivec/zigbee2mqtt.io that referenced this pull request Mar 15, 2025
Nerivec added a commit to Nerivec/zigbee-herdsman-converters that referenced this pull request Mar 15, 2025
Nerivec added a commit to Nerivec/zigbee-herdsman-converters that referenced this pull request Mar 16, 2025
@Nerivec Nerivec force-pushed the externaljs-dynamic-import branch from 8e1e385 to b9c1a52 Compare March 17, 2025 18:03
@Nerivec Nerivec force-pushed the externaljs-dynamic-import branch from 4fdb7a9 to cd7043d Compare March 17, 2025 23:22
@Nerivec
Copy link
Collaborator Author

Nerivec commented Mar 17, 2025

With the error handling now moving invalid files to the old directory (prevents constantly messing with Z2M and avoids extra code to bypass them everywhere), I'm thinking the contents of the old directory shouldn't be rotated by Z2M. It's not like there will be a lot of iterations by most users. Plus the archiving is only triggered when live-editing via MQTT, which is unlikely to be the favored option anyway.

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

Successfully merging this pull request may close these issues.

1 participant