Skip to content

Commit

Permalink
[BUGFIX] Update VM, fix component name preprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Garrett committed Jan 30, 2021
1 parent ae836ec commit 6d37785
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 158 deletions.
2 changes: 2 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const buildDebugMacroPlugin = require('./build-debug-macro-plugin');
const buildStripClassCallcheckPlugin = require('./build-strip-class-callcheck-plugin');
const injectBabelHelpers = require('./transforms/inject-babel-helpers').injectBabelHelpers;
const debugTree = require('broccoli-debug').buildDebugCallback('ember-source:addon');
const vmBabelPlugins = require('@glimmer/vm-babel-plugins');

const PRE_BUILT_TARGETS = [
'last 1 Chrome versions',
Expand Down Expand Up @@ -150,6 +151,7 @@ module.exports = {
plugins: [
babelHelperPlugin,
buildDebugMacroPlugin(!isProduction),
...vmBabelPlugins({ isDebug: !isProduction }),
[
require.resolve('@babel/plugin-transform-block-scoping'),
{ throwIfClosureRequired: true },
Expand Down
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@babel/plugin-transform-block-scoping": "^7.8.3",
"@babel/plugin-transform-object-assign": "^7.8.3",
"@ember/edition-utils": "^1.2.0",
"@glimmer/vm-babel-plugins": "0.74.0",
"babel-plugin-debug-macros": "^0.3.3",
"babel-plugin-filter-imports": "^4.0.0",
"broccoli-concat": "^4.2.4",
Expand All @@ -74,19 +75,19 @@
},
"devDependencies": {
"@babel/preset-env": "^7.9.5",
"@glimmer/compiler": "0.73.2",
"@glimmer/compiler": "0.74.0",
"@glimmer/env": "^0.1.7",
"@glimmer/global-context": "0.73.2",
"@glimmer/interfaces": "0.73.2",
"@glimmer/manager": "0.73.2",
"@glimmer/destroyable": "0.73.2",
"@glimmer/owner": "0.73.2",
"@glimmer/node": "0.73.2",
"@glimmer/opcode-compiler": "0.73.2",
"@glimmer/program": "0.73.2",
"@glimmer/reference": "0.73.2",
"@glimmer/runtime": "0.73.2",
"@glimmer/validator": "0.73.2",
"@glimmer/global-context": "0.74.0",
"@glimmer/interfaces": "0.74.0",
"@glimmer/manager": "0.74.0",
"@glimmer/destroyable": "0.74.0",
"@glimmer/owner": "0.74.0",
"@glimmer/node": "0.74.0",
"@glimmer/opcode-compiler": "0.74.0",
"@glimmer/program": "0.74.0",
"@glimmer/reference": "0.74.0",
"@glimmer/runtime": "0.74.0",
"@glimmer/validator": "0.74.0",
"@simple-dom/document": "^1.4.0",
"@types/qunit": "^2.9.1",
"@types/rsvp": "^4.0.3",
Expand Down
63 changes: 44 additions & 19 deletions packages/@ember/-internals/glimmer/lib/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Owner } from '@ember/-internals/owner';
import { getDebugName } from '@ember/-internals/utils';
import { constructStyleDeprecationMessage } from '@ember/-internals/views';
import { assert, deprecate, warn } from '@ember/debug';
import { DeprecationOptions } from '@ember/debug/lib/deprecate';
import { backburner, schedule } from '@ember/runloop';
import { DEBUG } from '@glimmer/env';
import setGlobalContext from '@glimmer/global-context';
Expand Down Expand Up @@ -50,29 +51,36 @@ setGlobalContext({
{ id: 'ember-htmlbars.style-xss-warning' }
);
},
});

if (DEBUG) {
setTrackingTransactionEnv!({
assert(message) {
assert(message, false);
},
assert(test: unknown, msg: string, options?: { id: string }) {
if (DEBUG) {
let id = options?.id;

deprecate(message) {
deprecate(message, false, {
id: 'autotracking.mutation-after-consumption',
until: '4.0.0',
for: 'ember-source',
since: {
enabled: '3.21.0',
},
});
},
let override = VM_ASSERTION_OVERRIDES.find((o) => o.id === id);

assert(override?.message ?? msg, test);
}
},

deprecate(msg: string, test: unknown, options: { id: string }) {
if (DEBUG) {
let { id } = options;

let override = VM_DEPRECATION_OVERRIDES.find((o) => o.id === id);

if (!override) throw new Error(`deprecation override for ${id} not found`);

deprecate(override.message ?? msg, Boolean(test), override);
}
},
});

if (DEBUG) {
setTrackingTransactionEnv?.({
debugMessage(obj, keyName) {
let dirtyString = keyName
? `\`${keyName}\` on \`${getDebugName!(obj)}\``
: `\`${getDebugName!(obj)}\``;
? `\`${keyName}\` on \`${getDebugName?.(obj)}\``
: `\`${getDebugName?.(obj)}\``;

return `You attempted to update ${dirtyString}, but it had already been used previously in the same computation. Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.`;
},
Expand All @@ -81,12 +89,29 @@ if (DEBUG) {

///////////

// VM Assertion/Deprecation overrides

const VM_DEPRECATION_OVERRIDES: (DeprecationOptions & { message?: string })[] = [
{
id: 'autotracking.mutation-after-consumption',
until: '4.0.0',
for: 'ember-source',
since: {
enabled: '3.21.0',
},
},
];

const VM_ASSERTION_OVERRIDES: { id: string; message: string }[] = [];

///////////

// Define environment delegate

export class EmberEnvironmentDelegate implements EnvironmentDelegate {
public enableDebugTooling: boolean = ENV._DEBUG_RENDER_TREE;

constructor(public owner: Owner, public isInteractive: boolean) {}

onTransactionCommit() {}
onTransactionCommit(): void {}
}
Loading

0 comments on commit 6d37785

Please sign in to comment.