diff --git a/packages/compat/src/default-pipeline.ts b/packages/compat/src/default-pipeline.ts index ebd0077e6..0d901d3d2 100644 --- a/packages/compat/src/default-pipeline.ts +++ b/packages/compat/src/default-pipeline.ts @@ -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 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( - emberApp: EmberAppInstance, - packager?: PackagerConstructor, - options: PipelineOptions = {} -): 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: { @@ -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; -} diff --git a/packages/compat/src/index.ts b/packages/compat/src/index.ts index 313e45051..ff459ffff 100644 --- a/packages/compat/src/index.ts +++ b/packages/compat/src/index.ts @@ -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'; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 4669188b6..ef8d1c435 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -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'; diff --git a/packages/core/src/to-broccoli-plugin.ts b/packages/core/src/to-broccoli-plugin.ts deleted file mode 100644 index 8c5621bcc..000000000 --- a/packages/core/src/to-broccoli-plugin.ts +++ /dev/null @@ -1,37 +0,0 @@ -import Plugin from 'broccoli-plugin'; -import type { Packager, PackagerConstructor, Variant } from './packager'; -import type Stage from './stage'; -import { tmpdir } from '@embroider/shared-internals'; - -interface BroccoliPackager { - new (stage: Stage, variants: Variant[], options?: Options): Plugin; -} - -export default function toBroccoliPlugin( - packagerClass: PackagerConstructor -): BroccoliPackager { - class PackagerRunner extends Plugin { - private packager: Packager | undefined; - constructor(private stage: Stage, private variants: Variant[], private options?: Options) { - super([stage.tree], { - persistentOutput: true, - needsCache: false, - annotation: packagerClass.annotation, - }); - } - - async build() { - if (!this.packager) { - this.packager = new packagerClass( - this.stage.inputPath, - this.outputPath, - this.variants, - msg => console.log(msg.split(tmpdir).join('$TMPDIR')), - this.options - ); - } - return this.packager.build(); - } - } - return PackagerRunner; -}