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

Updates for LTS 3.28 including ember-data #1085

Merged
merged 10 commits into from
Feb 8, 2022
1 change: 0 additions & 1 deletion packages/compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"debug": "^4.3.2",
"fs-extra": "^9.1.0",
"fs-tree-diff": "^2.0.1",
"heimdalljs": "^0.2.6",
"jsdom": "^16.6.0",
"lodash": "^4.17.21",
"pkg-up": "^3.1.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/compat/src/addon-dependency-rules/ember-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ let rules: PackageRules[] = [
'-private.js': {
dependsOnModules: ['@ember-data/record-data/-private'],
},
'-private/system/core-store.js': {
dependsOnModules: ['@ember-data/record-data/-private'],
},
},
},
];
Expand Down
11 changes: 1 addition & 10 deletions packages/compat/src/build-compat-addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@ import { Package } from '@embroider/core';
import SmooshPackageJSON from './smoosh-package-json';
import broccoliMergeTrees from 'broccoli-merge-trees';
import { Node } from 'broccoli-node-api';
import OneShot from './one-shot';
import buildFunnel from 'broccoli-funnel';
import { UnwatchedDir, WatchedDir } from 'broccoli-source';
import EmptyPackageTree from './empty-package-tree';

export default function cachedBuildCompatAddon(originalPackage: Package, v1Cache: V1InstanceCache): Node {
let tree = buildCompatAddon(originalPackage, v1Cache);
if (!originalPackage.mayRebuild) {
tree = new OneShot(tree, originalPackage.name);
}
return tree;
}

function buildCompatAddon(originalPackage: Package, v1Cache: V1InstanceCache): Node {
export default function buildCompatAddon(originalPackage: Package, v1Cache: V1InstanceCache): Node {
if (originalPackage.isV2Addon()) {
// this case is needed when a native-v2 addon depends on a
// non-native-v2 addon. (The non-native one will get rewritten and
Expand Down
11 changes: 11 additions & 0 deletions packages/compat/src/compat-addons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ import V1App from './v1-app';
import TreeSync from 'tree-sync';
import { WatchedDir } from 'broccoli-source';

// This build stage expects to be run with broccoli memoization enabled in order
// to get good rebuild performance. We turn it on by default here, but you can
// still explicitly turn it off by setting the env var to "false".
//
// As for safetly mutating process.env: broccoli doesn't read this until a Node
// executes its build hook, so as far as I can tell there's no way we could set
// this too late.
if (typeof process.env.BROCCOLI_ENABLED_MEMOIZE === 'undefined') {
process.env.BROCCOLI_ENABLED_MEMOIZE = 'true';
}

export default class CompatAddons implements Stage {
private didBuild = false;
private destDir: string;
Expand Down
60 changes: 0 additions & 60 deletions packages/compat/src/one-shot.ts

This file was deleted.

1 change: 1 addition & 0 deletions packages/compat/tests/dummy-app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ describe('dummy app tests', function () {
test('rebuilds addon code', async function () {
expectFile('../../components/example.hbs').matches(/hello/);
writeFileSync(join(project.baseDir, 'addon/components/example.hbs'), 'goodbye');
build.didChange(project.baseDir);
await build.rebuild();
expectFile('../../components/example.hbs').matches(/goodbye/);
});
Expand Down
4 changes: 4 additions & 0 deletions packages/compat/tests/stage2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ describe('stage2 build', function () {
test(`changes in app.css are propagated at rebuild`, async function () {
expectFile('assets/my-app.css').doesNotMatch('newly-added-class');
writeFileSync(join(app.baseDir, 'app/styles/app.css'), `.newly-added-class { color: red }`);
build.didChange(join(app.baseDir, 'app/styles'));
await build.rebuild();
expectFile('assets/my-app.css').matches('newly-added-class');
});
Expand All @@ -558,19 +559,22 @@ describe('stage2 build', function () {

test(`updated public asset`, async function () {
writeFileSync(join(app.baseDir, 'public/public-file-1.txt'), `updated state`);
build.didChange(join(app.baseDir, 'app'));
await build.rebuild();
expectFile('public-file-1.txt').matches(/updated state/);
});

test(`added public asset`, async function () {
writeFileSync(join(app.baseDir, 'public/public-file-2.txt'), `added`);
build.didChange(join(app.baseDir, 'app'));
await build.rebuild();
expectFile('public-file-2.txt').matches(/added/);
expectFile('package.json').json().get('ember-addon.assets').includes('public-file-2.txt');
});

test(`removed public asset`, async function () {
unlinkSync(join(app.baseDir, 'public/public-file-1.txt'));
build.didChange(join(app.baseDir, 'app'));
await build.rebuild();
expectFile('public-file-1.txt').doesNotExist();
expectFile('package.json').json().get('ember-addon.assets').doesNotInclude('public-file-1.txt');
Expand Down
14 changes: 14 additions & 0 deletions test-packages/support/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ export default class BuildResult {
}
}

// This allows our tests to simulate what a real Watcher would do, without
// managing all the asynchrony of a real Watcher.
//
// This is necessary once you have BROCCOLI_ENABLED_MEMOIZE=true.
async didChange(dir: string) {
let node = this.builder.watchedSourceNodeWrappers.find(nw => nw.nodeInfo.sourceDirectory === dir);
if (!node) {
throw new Error(
`test tried to simulated a watched file change in ${dir}, but we could not find the corresponding watched broccoli node`
);
}
node.revise();
}

async rebuild() {
let origDir = process.cwd();
try {
Expand Down
6 changes: 3 additions & 3 deletions tests/scenarios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@
"broccoli-persistent-filter": "^3.1.2",
"ember-bootstrap": "^4.6.3",
"ember-cli-3.16": "npm:ember-cli@~3.16.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, why keep 3.16 and drop 3.20?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Purely to keep the test suite smaller. We still support both, we're just testing the older one of the two and assuming it's unlikely that the newer one is broken if LTS releases on either side of it are working.

"ember-cli-3.20": "npm:ember-cli@~3.20.0",
"ember-cli-3.24": "npm:ember-cli@~3.24.0",
"ember-cli-3.28": "npm:ember-cli@~3.28.0",
"ember-cli-beta": "npm:ember-cli@beta",
"ember-cli-htmlbars-inline-precompile": "^2.1.0",
"ember-cli-htmlbars-3": "npm:ember-cli-htmlbars@3",
"ember-cli-latest": "npm:ember-cli@latest",
"ember-cli-fastboot": "^2.2.3",
"ember-composable-helpers": "^4.4.1",
"ember-data-3.16": "npm:ember-data@~3.16.0",
"ember-data-3.20": "npm:ember-data@~3.20.0",
"ember-data-3.24": "npm:ember-data@~3.24.0",
"ember-data-3.28": "npm:ember-data@~3.28.0",
"ember-data-latest": "npm:ember-data@latest",
"ember-engines": "^0.8.17",
"ember-inline-svg": "^0.2.1",
"ember-source-latest": "npm:ember-source@latest",
"ember-source-beta": "npm:ember-source@beta",
"ember-source-3.16": "npm:ember-source@~3.16.0",
"ember-source-3.20": "npm:ember-source@~3.20.0",
"ember-source-3.24": "npm:ember-source@~3.24.0",
"ember-source-3.28": "npm:ember-source@~3.28.0",
"ember-truth-helpers": "^3.0.0"
},
"volta": {
Expand Down
17 changes: 7 additions & 10 deletions tests/scenarios/scenarios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ async function lts_3_16(project: Project) {
project.linkDevDependency('@ember/string', { baseDir: __dirname });
}

async function lts_3_20(project: Project) {
project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source-3.20' });
project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli-3.20' });
project.linkDevDependency('ember-data', { baseDir: __dirname, resolveName: 'ember-data-3.20' });

// needed because the ember-inflector used by this ember-data version blows up without it
project.linkDevDependency('@ember/string', { baseDir: __dirname });
}

async function lts_3_24(project: Project) {
project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source-3.24' });
project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli-3.24' });
Expand All @@ -42,6 +33,12 @@ async function lts_3_24(project: Project) {
project.linkDevDependency('@ember/string', { baseDir: __dirname });
}

async function lts_3_28(project: Project) {
project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source-3.28' });
project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli-3.28' });
project.linkDevDependency('ember-data', { baseDir: __dirname, resolveName: 'ember-data-3.28' });
}

async function release(project: Project) {
project.linkDevDependency('ember-source', { baseDir: __dirname, resolveName: 'ember-source-latest' });
project.linkDevDependency('ember-cli', { baseDir: __dirname, resolveName: 'ember-cli-latest' });
Expand All @@ -51,8 +48,8 @@ async function release(project: Project) {
export function supportMatrix(scenarios: Scenarios) {
return scenarios.expand({
lts_3_16,
lts_3_20,
lts_3_24,
lts_3_28,
release,
});
}
Expand Down
6 changes: 6 additions & 0 deletions types/broccoli/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
declare module 'broccoli' {
import type { SourceNodeInfo } from 'broccoli-node-api';

export class Builder {
constructor(tree: unknown);
build(): Promise<void>;
cleanup(): Promise<void>;
outputPath: string;
readonly watchedSourceNodeWrappers: {
nodeInfo: SourceNodeInfo;
revise(): void;
}[];
}
}
16 changes: 0 additions & 16 deletions types/heimdalljs/index.d.ts

This file was deleted.

Loading