Skip to content

Conversation

@RoboErikG
Copy link
Contributor

The basics

Adds a check for the Blockly import to the migration script. Due to how the script is set up this will run every time, even if it's already correct, but that should be a no-op.

The details

Resolves

Fixes #2349

Proposed Changes

Adds a database entry to fix_imports.js for updating how Blockly gets imported
from:
import Blockly from 'blockly';
to:
import * as Blockly from 'blockly';

Because of how the migration script is set up there's no easy way to check if the import is already correct, so it will always perform the replacement if there are references to Blockly in the file. This shouldn't cause any visible change, so is just inefficient. This shouldn't be a problem given the usage of the migration script.

I also changed the manual test files from .txt to .js because the script was previously updated to only run against .js and .ts files to avoid modifying something unexpectedly.

Reason for Changes

import Blockly from 'blockly' isn't guaranteed to work correctly and should be import * as Blockly from 'blockly' instead.

Test Coverage

Ran mocha tests and the manual test files to verify.

Documentation

Additional Information

@RoboErikG RoboErikG requested a review from a team as a code owner March 5, 2025 23:10
@RoboErikG RoboErikG requested review from gonfunko and removed request for a team March 5, 2025 23:10
@RoboErikG
Copy link
Contributor Author

Working on disabling the lint checks for the test files...

@RoboErikG RoboErikG merged commit 14b6855 into RaspberryPiFoundation:master Mar 10, 2025
8 checks passed
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.

migration script: fix import Blockly from 'blockly'

2 participants