Skip to content

Commit

Permalink
Merge pull request #2179 from embroider-build/cleanup-default-pipeline
Browse files Browse the repository at this point in the history
removing unused functionality in default-pipeline
  • Loading branch information
ef4 authored Nov 22, 2024
2 parents 947c6d2 + a0471dc commit 0aa8fc6
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 109 deletions.
71 changes: 1 addition & 70 deletions packages/compat/src/default-pipeline.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,16 @@
import type Options from './options';
import { recommendedOptions } from './options';
import { App, Addons as CompatAddons } from '.';
import type { PackagerConstructor, Variant, EmberAppInstance } from '@embroider/core';
import { toBroccoliPlugin } from '@embroider/core';
import { tmpdir } from '@embroider/core';
import type { Variant, EmberAppInstance } from '@embroider/core';
import type { Node } from 'broccoli-node-api';
import writeFile from 'broccoli-file-creator';
import mergeTrees from 'broccoli-merge-trees';
import { createHash } from 'crypto';
import { join, dirname } from 'path';
import { sync as pkgUpSync } from 'pkg-up';

export interface PipelineOptions<PackagerOptions> extends Options {
packagerOptions?: PackagerOptions;
variants?: Variant[];
}

export function stableWorkspaceDir(appRoot: string, environment: string) {
let hash = createHash('md5');
hash.update(dirname(pkgUpSync({ cwd: appRoot })!));
hash.update(environment);
return join(tmpdir, 'embroider', hash.digest('hex').slice(0, 6));
}

export default function defaultPipeline<PackagerOptions>(
emberApp: EmberAppInstance,
packager?: PackagerConstructor<PackagerOptions>,
options: PipelineOptions<PackagerOptions> = {}
): Node {
let outputPath: string;
let addons;

let embroiderApp = new App(emberApp, options);

addons = new CompatAddons(embroiderApp);
addons.ready().then(result => {
outputPath = result.outputPath;
});

if (process.env.STAGE1_ONLY) {
return mergeTrees([addons.tree, writeFile('.stage1-output', () => outputPath)]);
}

if (process.env.STAGE2_ONLY || !packager) {
return mergeTrees([embroiderApp.asStage(addons).tree, writeFile('.stage2-output', () => outputPath)]);
}

let BroccoliPackager = toBroccoliPlugin(packager);
let variants = (options && options.variants) || defaultVariants(emberApp);
return new BroccoliPackager(embroiderApp.asStage(addons), variants, options && options.packagerOptions);
}

const defaultPrebuildOptions = {
...recommendedOptions.optimized,
amdCompatibility: {
Expand All @@ -75,32 +35,3 @@ export function prebuild(emberApp: EmberAppInstance, options?: Options): Node {

return mergeTrees([embroiderApp.asStage(addons).tree, writeFile('.stage2-output', () => outputPath)]);
}

function hasFastboot(emberApp: EmberAppInstance | EmberAppInstance) {
return emberApp.project.addons.find(a => a.name === 'ember-cli-fastboot');
}

function defaultVariants(emberApp: EmberAppInstance): Variant[] {
let variants: Variant[] = [];
if (emberApp.env === 'production') {
variants.push({
name: 'browser',
runtime: 'browser',
optimizeForProduction: true,
});
if (hasFastboot(emberApp)) {
variants.push({
name: 'fastboot',
runtime: 'fastboot',
optimizeForProduction: true,
});
}
} else {
variants.push({
name: 'dev',
runtime: hasFastboot(emberApp) ? 'all' : 'browser',
optimizeForProduction: false,
});
}
return variants;
}
2 changes: 1 addition & 1 deletion packages/compat/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ export { default as App } from './compat-app';
export { default as Addons } from './compat-addons';
export { default as Options, recommendedOptions } from './options';
export { default as V1Addon } from './v1-addon';
export { default as compatBuild, prebuild, PipelineOptions } from './default-pipeline';
export { prebuild, PipelineOptions } from './default-pipeline';
export { PackageRules, ModuleRules } from './dependency-rules';
1 change: 0 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export {
export { HTMLEntrypoint, BundleSummary } from './html-entrypoint';
export { default as Stage } from './stage';
export { default as Options, optionsWithDefaults } from './options';
export { default as toBroccoliPlugin } from './to-broccoli-plugin';
export { default as WaitForTrees, OutputPaths } from './wait-for-trees';
export { compile as jsHandlebarsCompile } from './js-handlebars';
export { todo, unsupported, warn, debug, expectWarning, throwOnWarnings } from './messages';
Expand Down
37 changes: 0 additions & 37 deletions packages/core/src/to-broccoli-plugin.ts

This file was deleted.

0 comments on commit 0aa8fc6

Please sign in to comment.