Revert "resourceloader: Modern ES6 code should be forced to target mobile"

This reverts commit 15622ea09a.

Reason for revert: T324525

Bug: T323542
Change-Id: I496ce3589f0322e7ac0f109081fa5e0587f48f94
This commit is contained in:
Kosta Harlan 2022-12-06 08:12:22 +00:00
parent 15622ea09a
commit e596af730d
2 changed files with 0 additions and 28 deletions

View file

@ -244,24 +244,6 @@ class FileModule extends Module {
break;
}
}
// In future this should be expanded to cover modules using packageFiles as well.
$isModernCode = $this->requiresES6();
if ( $isModernCode ) {
// If targets omitted, modern code should automatically default to mobile+desktop targets.
$isNotMobileTargeted = !in_array( 'mobile', $this->targets );
// Modern JavaScript should never be restricted to desktop-only (see T323542)
if ( $isNotMobileTargeted ) {
// Add the mobile target to these modules.
$this->targets[] = 'mobile';
$targetsSpecified = isset( $options['targets'] );
// If the user intentionally tried to avoid adding to mobile log a warning.
if ( $targetsSpecified ) {
$this->getLogger()->warning( "When 'es6' is enabled, module will automatically target mobile.", [
'module' => $this->getName(),
] );
}
}
}
if ( isset( $options['scripts'] ) && isset( $options['packageFiles'] ) ) {
throw new InvalidArgumentException( "A module may not set both 'scripts' and 'packageFiles'" );
}

View file

@ -958,15 +958,5 @@ class FileModuleTest extends ResourceLoaderTestCase {
$this->assertFalse( $module->requiresES6(), 'requiresES6 is false when set to false' );
$module = new FileModule( [ 'es6' => true ] );
$this->assertTrue( $module->requiresES6(), 'requiresES6 is true when set to true' );
$module = new FileModule( [ 'es6' => true, 'targets' => 'desktop' ] );
$this->assertEquals( $module->getTargets(), [ 'desktop', 'mobile' ], 'Targets ignored if es6 is set.' );
$module = new FileModule( [ 'es6' => true, 'targets' => [ 'desktop' ] ] );
$this->assertEquals( $module->getTargets(), [ 'desktop', 'mobile' ], 'Targets ignored if es6 is set.' );
// Check if it's still possible to define modules targetting mobile.
$module = new FileModule( [ 'es6' => true, 'targets' => 'mobile' ] );
$this->assertTrue( $module->requiresES6(), 'requiresES6 is true when set to true' );
$module = new FileModule( [ 'es6' => true, 'targets' => [ 'mobile' ] ] );
$this->assertTrue( $module->requiresES6(), 'requiresES6 is true when set to true' );
}
}