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 esbuild when possible for project builds #249

Merged
merged 4 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions cmd/extension/extension_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ var extensionAssetBundleCmd = &cobra.Command{
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
assetCfg := extension.AssetBuildConfig{
EnableESBuildForAdmin: false,
EnableESBuildForStorefront: false,
ShopwareRoot: os.Getenv("SHOPWARE_PROJECT_ROOT"),
ShopwareRoot: os.Getenv("SHOPWARE_PROJECT_ROOT"),
}
validatedExtensions := make([]extension.Extension, 0)

Expand All @@ -37,13 +35,6 @@ var extensionAssetBundleCmd = &cobra.Command{
validatedExtensions = append(validatedExtensions, ext)
}

if len(args) == 1 {
extCfg := validatedExtensions[0].GetExtensionConfig()

assetCfg.EnableESBuildForAdmin = extCfg.Build.Zip.Assets.EnableESBuildForAdmin
assetCfg.EnableESBuildForStorefront = extCfg.Build.Zip.Assets.EnableESBuildForStorefront
}

constraint, err := validatedExtensions[0].GetShopwareVersionConstraint()
if err != nil {
return fmt.Errorf("cannot get shopware version constraint: %w", err)
Expand Down
8 changes: 3 additions & 5 deletions cmd/extension/extension_zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,9 @@ var extensionZipCmd = &cobra.Command{
}

assetBuildConfig := extension.AssetBuildConfig{
EnableESBuildForAdmin: extCfg.Build.Zip.Assets.EnableESBuildForAdmin,
EnableESBuildForStorefront: extCfg.Build.Zip.Assets.EnableESBuildForStorefront,
CleanupNodeModules: true,
ShopwareRoot: os.Getenv("SHOPWARE_PROJECT_ROOT"),
ShopwareVersion: shopwareConstraint,
CleanupNodeModules: true,
ShopwareRoot: os.Getenv("SHOPWARE_PROJECT_ROOT"),
ShopwareVersion: shopwareConstraint,
}

if err := extension.BuildAssetsForExtensions(cmd.Context(), extension.ConvertExtensionsToSources(cmd.Context(), []extension.Extension{tempExt}), assetBuildConfig); err != nil {
Expand Down
2 changes: 0 additions & 2 deletions cmd/project/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ var projectCI = &cobra.Command{
}

assetCfg := extension.AssetBuildConfig{
EnableESBuildForAdmin: false,
EnableESBuildForStorefront: false,
CleanupNodeModules: true,
ShopwareRoot: args[0],
ShopwareVersion: constraint,
Expand Down
12 changes: 8 additions & 4 deletions extension/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ func ConvertExtensionsToSources(ctx context.Context, extensions []Extension) []a
}

sources = append(sources, asset.Source{
Name: name,
Path: ext.GetRootDir(),
Name: name,
Path: ext.GetRootDir(),
AdminEsbuildCompatible: ext.GetExtensionConfig().Build.Zip.Assets.EnableESBuildForAdmin,
StorefrontEsbuildCompatible: ext.GetExtensionConfig().Build.Zip.Assets.EnableESBuildForStorefront,
})

extConfig := ext.GetExtensionConfig()
Expand All @@ -35,8 +37,10 @@ func ConvertExtensionsToSources(ctx context.Context, extensions []Extension) []a
}

sources = append(sources, asset.Source{
Name: bundleName,
Path: path.Join(ext.GetRootDir(), bundle.Path),
Name: bundleName,
Path: path.Join(ext.GetRootDir(), bundle.Path),
AdminEsbuildCompatible: ext.GetExtensionConfig().Build.Zip.Assets.EnableESBuildForAdmin,
StorefrontEsbuildCompatible: ext.GetExtensionConfig().Build.Zip.Assets.EnableESBuildForStorefront,
})
}
}
Expand Down
Loading
Loading