Skip to content

Commit

Permalink
Merge pull request #10106 from bertdeblock/remove-deprecated-PACKAGER…
Browse files Browse the repository at this point in the history
…-experiment

[CLEANUP] Remove deprecated `PACKAGER` experiment
  • Loading branch information
Bert De Block committed Mar 18, 2023
2 parents fc8ab5d + b527fa9 commit 9652ab3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 264 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ jobs:
matrix:
feature-flag:
- ENABLE_ALL_EXPERIMENTS
- PACKAGER
- EMBROIDER
- CLASSIC

Expand Down
50 changes: 2 additions & 48 deletions lib/broccoli/ember-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const logger = require('heimdalljs-logger')('ember-cli:ember-app');
const addonProcessTree = require('../utilities/addon-process-tree');
const lintAddonsByType = require('../utilities/lint-addons-by-type');
const emberCLIBabelConfigKey = require('../utilities/ember-cli-babel-config-key');
const { isExperimentEnabled } = require('../experiments');
const semver = require('semver');
const DefaultPackager = require('./default-packager');
const { deprecate } = require('../debug');
Expand Down Expand Up @@ -164,7 +163,6 @@ class EmberApp {
},
});

this._isPackageHookSupplied = typeof this.options.package === 'function';
this._cachedAddonBundles = {};

if (this.project.perBundleAddonCache && this.project.perBundleAddonCache.numProxies > 0) {
Expand Down Expand Up @@ -867,37 +865,6 @@ class EmberApp {
return tree;
}

_precompileAppJsTree(tree) {
let emberCLIBabelConfigKey = this._emberCLIBabelConfigKey();

let original = this.options[emberCLIBabelConfigKey];

// the app will handle transpilation after it tree-shakes
// do it here instead of the constructor because
// ember-data and others do their own compilation in their
// treeForAddon without calling super
// they need the original params preserved because they call
// babel themselves and expect compilation the old way
this.options[emberCLIBabelConfigKey] = Object.assign({}, original, {
compileModules: false,
disablePresetEnv: true,
disableDebugTooling: true,
disableEmberModulesAPIPolyfill: true,
});

tree = preprocessJs(tree, '/', '/', {
annotation: `_precompileAppJsTree`,
registry: this.registry,
treeType: 'app',
});

// return the original params because there are multiple
// entrances to preprocessJs
this.options[emberCLIBabelConfigKey] = original;

return tree;
}

/**
Runs addon post-processing on a given tree and returns the processed tree.
Expand Down Expand Up @@ -1076,7 +1043,7 @@ class EmberApp {
* @method getAppJavascript
* @return {BroccoliTree}
*/
getAppJavascript(isPackageHookSupplied) {
getAppJavascript() {
let appTrees = [].concat(this.addonTreesFor('app'), this.trees.app).filter(Boolean);

let mergedApp = mergeTrees(appTrees, {
Expand All @@ -1090,10 +1057,6 @@ class EmberApp {
annotation: 'ProcessedAppTree',
});

if (isExperimentEnabled('PACKAGER') && isPackageHookSupplied) {
appTree = this._precompileAppJsTree(appTree);
}

return appTree;
}

Expand Down Expand Up @@ -1631,7 +1594,7 @@ class EmberApp {
this.getTests(),
this.getExternalTree(),
this.getPublic(),
this.getAppJavascript(this._isPackageHookSupplied),
this.getAppJavascript(),
].filter(Boolean);
}

Expand Down Expand Up @@ -1731,7 +1694,6 @@ class EmberApp {
*/
toTree(additionalTrees) {
let packagedTree;
let packageFn = this.options.package;

let fullTree = mergeTrees(this.toArray(), {
overwrite: true,
Expand All @@ -1740,14 +1702,6 @@ class EmberApp {

fullTree = this._debugTree(fullTree, 'prepackage');

if (isExperimentEnabled('PACKAGER')) {
if (this._isPackageHookSupplied) {
packagedTree = packageFn.call(this, fullTree);
} else {
this.project.ui.writeWarnLine('`package` hook must be a function, falling back to default packaging.');
}
}

if (!packagedTree) {
packagedTree = this._legacyPackage(fullTree);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/experiments/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

const chalk = require('chalk');
const availableExperiments = Object.freeze(['PACKAGER', 'EMBROIDER', 'CLASSIC']);
const availableExperiments = Object.freeze(['EMBROIDER', 'CLASSIC']);

const deprecatedExperiments = Object.freeze(['PACKAGER']);
const deprecatedExperiments = Object.freeze([]);
const enabledExperiments = Object.freeze([]);
const deprecatedExperimentsDeprecationsIssued = [];

Expand Down
213 changes: 0 additions & 213 deletions tests/unit/broccoli/ember-app-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const createBuilder = broccoliTestHelper.createBuilder;
const createTempDir = broccoliTestHelper.createTempDir;

const MockCLI = require('../../helpers/mock-cli');
const { isExperimentEnabled } = require('../../../lib/experiments');
const mergeTrees = require('../../../lib/broccoli/merge-trees');
const BroccoliMergeTrees = require('broccoli-merge-trees').MergeTrees;

let EmberApp = require('../../../lib/broccoli/ember-app');
Expand Down Expand Up @@ -56,217 +54,6 @@ describe('EmberApp', function () {
project = setupProject(projectPath);
});

if (isExperimentEnabled('PACKAGER')) {
describe('packager hook', function () {
let js, input, output;

before(async function () {
js = await createTempDir();
js.write({
fake: {
javascript: '// javascript.js',
},
});
});

beforeEach(async function () {
input = await createTempDir();
});

afterEach(async function () {
await input.dispose();
if (output) {
await output.dispose();
}
});

after(async function () {
await js.dispose();
});

it('sets `_isPackageHookSupplied` to `false` if `package` hook is not a function', function () {
let app = new EmberApp({
project,
package: false,
});

expect(app._isPackageHookSupplied).to.equal(false);
});

it('sets `_isPackageHookSupplied` to `false` if `package` hook is not supplied', function () {
let app = new EmberApp({
project,
});

expect(app._isPackageHookSupplied).to.equal(false);
});

it('sets `_isPackageHookSupplied` to `true` if `package` hook is supplied', function () {
let app = new EmberApp({
project,
package: () => input.path(),
});

expect(app._isPackageHookSupplied).to.equal(true);
});

it('overrides the output of the build', async function () {
input.write({
fake: {
dist: {
'foo.js': '// foo.js',
},
},
});

let app = new EmberApp({
project,
package: () => input.path(),
});
mockTemplateRegistry(app);

output = createBuilder(app.toTree());
await output.build();

let outputFiles = output.read();

expect(outputFiles).to.deep.equal({
fake: {
dist: {
'foo.js': '// foo.js',
},
},
});
});

it('receives a full tree as an argument', async function () {
let appStyles = await createTempDir();
appStyles.write({
'app.css': '// css styles',
});
input.write({
fake: {
dist: {
'foo.js': '// foo.js',
},
},
});

let app = new EmberApp({
project,
package: (tree) => mergeTrees([tree, input.path()]),
trees: {
styles: appStyles.path(),
},
});
mockTemplateRegistry(app);

app.getAppJavascript = () => js.path();

output = createBuilder(app.toTree());
await output.build();

let outputFiles = output.read();

expect(outputFiles).to.deep.equal({
'addon-tree-output': {},
fake: {
dist: {
'foo.js': '// foo.js',
},
javascript: '// javascript.js',
},
app: {
styles: {
'app.css': '// css styles',
},
},
'test-project': {
templates: {},
},
tests: {
'.gitkeep': '',
'addon-test-support': {},
lint: {},
},
public: {},
vendor: {
'.gitkeep': '',
},
});
});

it('prints a warning if `package` is not a function and falls back to default packaging', async function () {
let app = new EmberApp({
project,
package: {},
});

app.project.ui.writeWarnLine = td.function();

app.getAppJavascript = td.function();
app.getAddonTemplates = td.function();
app.getStyles = td.function();
app.getTests = td.function();
app.getExternalTree = td.function();
app._legacyAddonCompile = td.function();
app._defaultPackager = {
packagePublic: td.function(),
packageJavascript: td.function(),
packageStyles: td.function(),
processIndex: td.function(),
importAdditionalAssets: td.function(),
packageTests: td.function(),
};

output = createBuilder(app.toTree());
await output.build();

td.verify(app.getAppJavascript(false));
td.verify(app.getStyles());
td.verify(app.getTests());
td.verify(app.getExternalTree());
td.verify(
app.project.ui.writeWarnLine('`package` hook must be a function, falling back to default packaging.')
);
});

it('receives transpiled ES current app tree', async function () {
let app = new EmberApp({
project,
package: (tree) => tree,
});
mockTemplateRegistry(app);

input.write({
fake: {
dist: {
'foo.js': '// foo.js',
},
},
});
app.registry.add('js', {
name: 'fake-js-preprocessor',
ext: 'js',
toTree() {
return input.path();
},
});

output = createBuilder(app.toTree());
await output.build();

let outputFiles = output.read();

expect(outputFiles.fake).to.deep.equal({
dist: {
'foo.js': '// foo.js',
},
});
});
});
}

describe('getStyles()', function () {
it('can handle empty styles folders', async function () {
let appStyles = await createTempDir();
Expand Down

0 comments on commit 9652ab3

Please sign in to comment.