From ddc2e966754351c5751910e229cd8edb7f94f6c5 Mon Sep 17 00:00:00 2001 From: Chirag Patel Date: Wed, 6 Jan 2021 13:15:37 -0800 Subject: [PATCH] Rename createTemplate to precompileTemplate to match spec defined in rfc --- packages/@glimmer/blueprint/files/src/App.js | 4 +- .../component/test/interactive/args-test.ts | 6 +-- .../test/interactive/lifecycle-hook-test.ts | 8 ++-- packages/@glimmer/core/index.ts | 2 +- packages/@glimmer/core/src/template.ts | 6 +-- .../@glimmer/core/test/interactive/fn-test.ts | 12 +++--- .../core/test/interactive/modifier-test.ts | 4 +- .../core/test/interactive/render-test.ts | 12 +++--- .../core/test/non-interactive/each-test.ts | 16 ++++---- .../core/test/non-interactive/render-test.ts | 40 +++++++++---------- .../core/test/non-interactive/to-bool-test.ts | 6 +-- packages/@glimmer/ssr/test/modifiers-test.ts | 4 +- .../@glimmer/ssr/test/render-options-tests.ts | 6 +-- .../index.js | 12 +++--- .../errors/non-existent-component/code.js | 4 +- .../precompile/ast-transform/code.js | 4 +- .../test/fixtures/custom-imports/code.js | 2 +- .../test/fixtures/first-parameter/code.js | 6 +-- .../fixtures/rename-scope-variable/code.js | 4 +- .../test/fixtures/second-parameter/code.js | 6 +-- .../example-apps/basic/src/MyComponent.ts | 6 +-- .../example-apps/basic/src/OtherComponent.ts | 4 +- .../src/RehydratableCounter.ts | 4 +- .../src/RehydratableRegion.ts | 4 +- .../src/StaticComponent.ts | 4 +- .../rehydration/src/MyComponent.ts | 4 +- 26 files changed, 95 insertions(+), 95 deletions(-) diff --git a/packages/@glimmer/blueprint/files/src/App.js b/packages/@glimmer/blueprint/files/src/App.js index bdab40f68..db2dc3b70 100644 --- a/packages/@glimmer/blueprint/files/src/App.js +++ b/packages/@glimmer/blueprint/files/src/App.js @@ -1,5 +1,5 @@ import Component from '@glimmer/component'; -import { setComponentTemplate, createTemplate } from '@glimmer/core'; +import { setComponentTemplate, precompileTemplate } from '@glimmer/core'; import logo from './logo.svg'; import './App.css'; @@ -9,7 +9,7 @@ export default class App extends Component { } setComponentTemplate( - createTemplate(` + precompileTemplate(`
diff --git a/packages/@glimmer/component/test/interactive/args-test.ts b/packages/@glimmer/component/test/interactive/args-test.ts index 1142c9918..f6dbf1f4b 100644 --- a/packages/@glimmer/component/test/interactive/args-test.ts +++ b/packages/@glimmer/component/test/interactive/args-test.ts @@ -1,7 +1,7 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; -import { setComponentTemplate, createTemplate } from '@glimmer/core'; +import { setComponentTemplate, precompileTemplate } from '@glimmer/core'; import { test, render, settled } from '@glimmer/core/test/utils'; QUnit.module('[@glimmer/component] Component Arguments', () => { @@ -27,14 +27,14 @@ QUnit.module('[@glimmer/component] Component Arguments', () => { } setComponentTemplate( - createTemplate( + precompileTemplate( { ChildComponent }, '' ), ParentComponent ); - setComponentTemplate(createTemplate('{{this.name}} {{@status}}'), ChildComponent); + setComponentTemplate(precompileTemplate('{{this.name}} {{@status}}'), ChildComponent); assert.equal(await render(ParentComponent), 'Tom Dale is dope'); diff --git a/packages/@glimmer/component/test/interactive/lifecycle-hook-test.ts b/packages/@glimmer/component/test/interactive/lifecycle-hook-test.ts index 533bb79f2..f7d77f16f 100644 --- a/packages/@glimmer/component/test/interactive/lifecycle-hook-test.ts +++ b/packages/@glimmer/component/test/interactive/lifecycle-hook-test.ts @@ -2,7 +2,7 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { test, render, settled } from '@glimmer/core/test/utils'; -import { setComponentTemplate, createTemplate } from '@glimmer/core'; +import { setComponentTemplate, precompileTemplate } from '@glimmer/core'; QUnit.module('[@glimmer/component] Lifecycle Hooks', () => { test('Lifecycle hook ordering', async function (assert) { @@ -37,7 +37,7 @@ QUnit.module('[@glimmer/component] Lifecycle Hooks', () => { class Component5 extends HookLoggerComponent {} setComponentTemplate( - createTemplate( + precompileTemplate( { Component2, Component3 }, ` {{#if this.showChildren}} @@ -50,7 +50,7 @@ QUnit.module('[@glimmer/component] Lifecycle Hooks', () => { ); setComponentTemplate( - createTemplate( + precompileTemplate( { Component4, Component5 }, ` {{@firstName}} @@ -61,7 +61,7 @@ QUnit.module('[@glimmer/component] Lifecycle Hooks', () => { Component2 ); - const emptyTemplate = createTemplate(''); + const emptyTemplate = precompileTemplate(''); setComponentTemplate(emptyTemplate, Component3); setComponentTemplate(emptyTemplate, Component4); diff --git a/packages/@glimmer/core/index.ts b/packages/@glimmer/core/index.ts index 52eec018c..98fa4aaf8 100644 --- a/packages/@glimmer/core/index.ts +++ b/packages/@glimmer/core/index.ts @@ -31,4 +31,4 @@ export { export { getOwner, setOwner } from '@glimmer/owner'; -export { createTemplate, setComponentTemplate } from './src/template'; +export { precompileTemplate, setComponentTemplate } from './src/template'; diff --git a/packages/@glimmer/core/src/template.ts b/packages/@glimmer/core/src/template.ts index c11de33a1..534160887 100644 --- a/packages/@glimmer/core/src/template.ts +++ b/packages/@glimmer/core/src/template.ts @@ -4,15 +4,15 @@ import { SerializedTemplateWithLazyBlock, Dict } from '@glimmer/interfaces'; import { templateFactory } from '@glimmer/opcode-compiler'; // This is provided by the `babel-plugin-strict-template-precompile` plugin -export let createTemplate: ( +export let precompileTemplate: ( scopeOrTemplate: Dict | string, template?: string ) => SerializedTemplateWithLazyBlock; if (DEBUG) { - createTemplate = (): SerializedTemplateWithLazyBlock => { + precompileTemplate = (): SerializedTemplateWithLazyBlock => { throw new Error( - 'createTemplate() is meant to be preprocessed with a babel plugin, @glimmer/babel-plugin-strict-template-precompile. If you are seeing this error message, it means that you do not have this babel plugin installed, or it is not enabled correctly' + 'precompileTemplate() is meant to be preprocessed with a babel plugin, @glimmer/babel-plugin-strict-template-precompile. If you are seeing this error message, it means that you do not have this babel plugin installed, or it is not enabled correctly' ); }; } diff --git a/packages/@glimmer/core/test/interactive/fn-test.ts b/packages/@glimmer/core/test/interactive/fn-test.ts index 862812690..9a7ef3116 100644 --- a/packages/@glimmer/core/test/interactive/fn-test.ts +++ b/packages/@glimmer/core/test/interactive/fn-test.ts @@ -3,7 +3,7 @@ import Component from '@glimmer/component'; import { fn } from '@glimmer/helper'; import { on, action } from '@glimmer/modifier'; -import { setComponentTemplate, createTemplate, templateOnlyComponent } from '@glimmer/core'; +import { setComponentTemplate, precompileTemplate, templateOnlyComponent } from '@glimmer/core'; QUnit.module('[@glimmer/core] interactive - {{fn}}', () => { test('can curry arguments via fn', async function (assert) { @@ -29,7 +29,7 @@ QUnit.module('[@glimmer/core] interactive - {{fn}}', () => { } setComponentTemplate( - createTemplate( + precompileTemplate( { on, fn }, '' ), @@ -82,12 +82,12 @@ QUnit.module('[@glimmer/core] interactive - {{fn}}', () => { } const Grandchild = setComponentTemplate( - createTemplate({ on, fn }, ''), + precompileTemplate({ on, fn }, ''), templateOnlyComponent() ); const Child = setComponentTemplate( - createTemplate( + precompileTemplate( { Grandchild, fn }, '
' ), @@ -95,7 +95,7 @@ QUnit.module('[@glimmer/core] interactive - {{fn}}', () => { ); setComponentTemplate( - createTemplate( + precompileTemplate( { Child, fn }, '
' ), @@ -116,7 +116,7 @@ QUnit.module('[@glimmer/core] interactive - {{fn}}', () => { class Parent extends Component {} setComponentTemplate( - createTemplate({ on, fn }, ''), + precompileTemplate({ on, fn }, ''), Parent ); diff --git a/packages/@glimmer/core/test/interactive/modifier-test.ts b/packages/@glimmer/core/test/interactive/modifier-test.ts index 1a12237e6..9e033a78a 100644 --- a/packages/@glimmer/core/test/interactive/modifier-test.ts +++ b/packages/@glimmer/core/test/interactive/modifier-test.ts @@ -2,7 +2,7 @@ import { test, render, settled, tracked } from '../utils'; import { click } from '../utils/dom'; import { on, action } from '@glimmer/modifier'; import Component from '@glimmer/component'; -import { setComponentTemplate, createTemplate } from '@glimmer/core'; +import { setComponentTemplate, precompileTemplate } from '@glimmer/core'; QUnit.module('Modifier Tests', () => { test('Supports the on modifier', async (assert) => { @@ -16,7 +16,7 @@ QUnit.module('Modifier Tests', () => { } setComponentTemplate( - createTemplate( + precompileTemplate( { on }, `` ), diff --git a/packages/@glimmer/core/test/interactive/render-test.ts b/packages/@glimmer/core/test/interactive/render-test.ts index 45fbd765d..d1048f655 100644 --- a/packages/@glimmer/core/test/interactive/render-test.ts +++ b/packages/@glimmer/core/test/interactive/render-test.ts @@ -1,4 +1,4 @@ -import { createTemplate } from '@glimmer/core'; +import { precompileTemplate } from '@glimmer/core'; import { test, render } from '../utils'; @@ -11,8 +11,8 @@ QUnit.module(`[@glimmer/core] interactive rendering tests`, () => { const firstContainerElement = document.createElement('div'); const secondContainerElement = document.createElement('div'); - await render(createTemplate(`

Hello Glimmer!

`), firstContainerElement); - await render(createTemplate(`

Hello Robbie!

`), secondContainerElement); + await render(precompileTemplate(`

Hello Glimmer!

`), firstContainerElement); + await render(precompileTemplate(`

Hello Robbie!

`), secondContainerElement); assert.equal(firstContainerElement.innerHTML, '

Hello Glimmer!

'); assert.equal(secondContainerElement.innerHTML, '

Hello Robbie!

'); @@ -30,7 +30,7 @@ QUnit.module(`[@glimmer/core] interactive rendering tests`, () => { containerElement.appendChild(previousSibling); containerElement.appendChild(document.createTextNode('bar')); - await render(createTemplate(`

Hello Glimmer!

`), containerElement); + await render(precompileTemplate(`

Hello Glimmer!

`), containerElement); assert.equal(containerElement.innerHTML, '

foo

bar

Hello Glimmer!

'); }); @@ -40,7 +40,7 @@ QUnit.module(`[@glimmer/core] interactive rendering tests`, () => { containerElement.innerHTML = '

Hello World

'; - await render(createTemplate(`

Hello World

`), { + await render(precompileTemplate(`

Hello World

`), { element: containerElement, rehydrate: true, }); @@ -53,7 +53,7 @@ QUnit.module(`[@glimmer/core] interactive rendering tests`, () => { containerElement.innerHTML = '

Hello World

'; - await render(createTemplate(`

Hello {{@name}}

`), { + await render(precompileTemplate(`

Hello {{@name}}

`), { element: containerElement.querySelector('#test')!, rehydrate: true, args: { diff --git a/packages/@glimmer/core/test/non-interactive/each-test.ts b/packages/@glimmer/core/test/non-interactive/each-test.ts index d013b4c1f..3a5d4fd75 100644 --- a/packages/@glimmer/core/test/non-interactive/each-test.ts +++ b/packages/@glimmer/core/test/non-interactive/each-test.ts @@ -1,7 +1,7 @@ import Component from '@glimmer/component'; import { test, render } from '../utils'; -import { setComponentTemplate, createTemplate } from '@glimmer/core'; +import { setComponentTemplate, precompileTemplate } from '@glimmer/core'; function freeze(array: T[]): ReadonlyArray> { return Object.freeze(array.slice().map(Object.freeze)); @@ -23,7 +23,7 @@ QUnit.module('[@glimmer/core] each helper', () => { const Component = class extends HelloWorld {}; setComponentTemplate( - createTemplate( + precompileTemplate( `
    {{#each this.strings key="@unknown" as |item|}}
  • {{item}}
  • {{/each}}
` ), Component @@ -38,7 +38,7 @@ QUnit.module('[@glimmer/core] each helper', () => { const Component = class extends HelloWorld {}; setComponentTemplate( - createTemplate( + precompileTemplate( `
    {{#each this.numbers key="@index" as |item|}}
  • {{item}}
  • {{/each}}
` ), Component @@ -53,7 +53,7 @@ QUnit.module('[@glimmer/core] each helper', () => { const Component = class extends HelloWorld {}; setComponentTemplate( - createTemplate( + precompileTemplate( `
    {{#each this.frozenNumbers key="@index" as |item|}}
  • {{item}}
  • {{/each}}
` ), Component @@ -68,7 +68,7 @@ QUnit.module('[@glimmer/core] each helper', () => { const Component = class extends HelloWorld {}; setComponentTemplate( - createTemplate( + precompileTemplate( `
    {{#each this.strings key="@index" as |item|}}
  • {{item}}
  • {{/each}}
` ), Component @@ -83,7 +83,7 @@ QUnit.module('[@glimmer/core] each helper', () => { const Component = class extends HelloWorld {}; setComponentTemplate( - createTemplate( + precompileTemplate( `
    {{#each this.frozenStrings key="@index" as |item|}}
  • {{item}}
  • {{/each}}
` ), Component @@ -98,7 +98,7 @@ QUnit.module('[@glimmer/core] each helper', () => { const Component = class extends HelloWorld {}; setComponentTemplate( - createTemplate( + precompileTemplate( `
    {{#each this.objects key="@index" as |item|}}
  • {{item.name}}
  • {{/each}}
` ), Component @@ -113,7 +113,7 @@ QUnit.module('[@glimmer/core] each helper', () => { const Component = class extends HelloWorld {}; setComponentTemplate( - createTemplate( + precompileTemplate( `
    {{#each this.frozenObjects key="@index" as |item|}}
  • {{item.name}}
  • {{/each}}
` ), Component diff --git a/packages/@glimmer/core/test/non-interactive/render-test.ts b/packages/@glimmer/core/test/non-interactive/render-test.ts index ce6771fb7..330f90d2b 100644 --- a/packages/@glimmer/core/test/non-interactive/render-test.ts +++ b/packages/@glimmer/core/test/non-interactive/render-test.ts @@ -5,7 +5,7 @@ import { on, action } from '@glimmer/modifier'; import { setComponentTemplate, - createTemplate, + precompileTemplate, getOwner, templateOnlyComponent, } from '@glimmer/core'; @@ -16,7 +16,7 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { test('it renders a component', async (assert) => { class MyComponent extends Component {} - setComponentTemplate(createTemplate(`

Hello world

`), MyComponent); + setComponentTemplate(precompileTemplate(`

Hello world

`), MyComponent); const html = await render(MyComponent); assert.strictEqual(html, '

Hello world

', 'the template was rendered'); @@ -26,11 +26,11 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { test('a component can render a nested component', async (assert) => { class OtherComponent extends Component {} - setComponentTemplate(createTemplate(`Hello world`), OtherComponent); + setComponentTemplate(precompileTemplate(`Hello world`), OtherComponent); class MyComponent extends Component {} setComponentTemplate( - createTemplate({ OtherComponent }, `

`), + precompileTemplate({ OtherComponent }, `

`), MyComponent ); @@ -41,20 +41,20 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { test('a component can render multiple nested components', async (assert) => { class Foo extends Component {} - setComponentTemplate(createTemplate(`Foo`), Foo); + setComponentTemplate(precompileTemplate(`Foo`), Foo); class Bar extends Component {} - setComponentTemplate(createTemplate(`Bar`), Bar); + setComponentTemplate(precompileTemplate(`Bar`), Bar); class OtherComponent extends Component {} setComponentTemplate( - createTemplate({ Foo, Bar }, `Hello world `), + precompileTemplate({ Foo, Bar }, `Hello world `), OtherComponent ); class MyComponent extends Component {} setComponentTemplate( - createTemplate({ OtherComponent }, `

`), + precompileTemplate({ OtherComponent }, `

`), MyComponent ); @@ -65,7 +65,7 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { test('custom elements are rendered', async function (assert) { const component = setComponentTemplate( - createTemplate('foo'), + precompileTemplate('foo'), templateOnlyComponent() ); @@ -75,7 +75,7 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { test('a component can render with args', async (assert) => { class MyComponent extends Component {} - setComponentTemplate(createTemplate('

{{@say}}

'), MyComponent); + setComponentTemplate(precompileTemplate('

{{@say}}

'), MyComponent); const renderOptions = { args: { @@ -97,12 +97,12 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { } const HelloWorld = setComponentTemplate( - createTemplate('{{yield @name}}!'), + precompileTemplate('{{yield @name}}!'), templateOnlyComponent() ); setComponentTemplate( - createTemplate( + precompileTemplate( { HelloWorld }, '{{name}}' ), @@ -132,7 +132,7 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { } setComponentTemplate( - createTemplate('Hello {{if this.pred this.salutation this.alternative}}!'), + precompileTemplate('Hello {{if this.pred this.salutation this.alternative}}!'), Main ); @@ -154,14 +154,14 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { // test('can render a component with the component helper', async function(assert) { // const HelloWorld = templateOnlyComponent(); - // setComponentTemplate(HelloWorld, createTemplate('

Hello {{@name}}!

')); + // setComponentTemplate(HelloWorld, precompileTemplate('

Hello {{@name}}!

')); // class MainComponent extends Component { // salutation = 'Glimmer'; // HelloWorld = HelloWorld; // } - // setComponentTemplate(MainComponent, createTemplate('{{component this.HelloWorld name=salutation}}')); + // setComponentTemplate(MainComponent, precompileTemplate('{{component this.HelloWorld name=salutation}}')); // assert.equal(await render(MainComponent), 'Hello Glimmer!'); // }); @@ -185,7 +185,7 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { } } - setComponentTemplate(createTemplate('

{{this.myLocale}}

'), MyComponent); + setComponentTemplate(precompileTemplate('

{{this.myLocale}}

'), MyComponent); const html = await render(MyComponent, { owner: new Owner(), @@ -197,7 +197,7 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { test('a component can be rendered more than once', async (assert) => { class MyComponent extends Component {} - setComponentTemplate(createTemplate(`

Bump

`), MyComponent); + setComponentTemplate(precompileTemplate(`

Bump

`), MyComponent); let html = await render(MyComponent); assert.strictEqual(html, '

Bump

', 'the component rendered'); @@ -219,7 +219,7 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { } setComponentTemplate( - createTemplate( + precompileTemplate( { on }, `` ), @@ -233,7 +233,7 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { test('it can set a dynamic href on an anchor', async (assert) => { class MyComponent extends Component {} - setComponentTemplate(createTemplate(`Link`), MyComponent); + setComponentTemplate(precompileTemplate(`Link`), MyComponent); const html = await render(MyComponent, { args: { href: 'www.example.com' } }); assert.strictEqual(html, 'Link', 'the template was rendered'); @@ -242,7 +242,7 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { test('it can set a dynamic src on an img', async (assert) => { class MyComponent extends Component {} - setComponentTemplate(createTemplate(``), MyComponent); + setComponentTemplate(precompileTemplate(``), MyComponent); const html = await render(MyComponent, { args: { src: './logo.svg' } }); assert.strictEqual(html, '', 'the template was rendered'); diff --git a/packages/@glimmer/core/test/non-interactive/to-bool-test.ts b/packages/@glimmer/core/test/non-interactive/to-bool-test.ts index f30f57b61..09e89157e 100644 --- a/packages/@glimmer/core/test/non-interactive/to-bool-test.ts +++ b/packages/@glimmer/core/test/non-interactive/to-bool-test.ts @@ -1,6 +1,6 @@ import Component from '@glimmer/component'; -import { setComponentTemplate, createTemplate } from '@glimmer/core'; +import { setComponentTemplate, precompileTemplate } from '@glimmer/core'; import { test, render } from '../utils'; @@ -13,7 +13,7 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { } setComponentTemplate( - createTemplate('Hello {{if this.pred this.salutation this.alternative}}!'), + precompileTemplate('Hello {{if this.pred this.salutation this.alternative}}!'), Main ); @@ -26,7 +26,7 @@ QUnit.module(`[@glimmer/core] non-interactive rendering tests`, () => { } setComponentTemplate( - createTemplate('Hello {{#if this.pred}}Glimmer{{else}}Glimmer.js{{/if}}!'), + precompileTemplate('Hello {{#if this.pred}}Glimmer{{else}}Glimmer.js{{/if}}!'), Main ); diff --git a/packages/@glimmer/ssr/test/modifiers-test.ts b/packages/@glimmer/ssr/test/modifiers-test.ts index 33bd3ce44..756d2403c 100644 --- a/packages/@glimmer/ssr/test/modifiers-test.ts +++ b/packages/@glimmer/ssr/test/modifiers-test.ts @@ -1,6 +1,6 @@ import { setComponentTemplate, - createTemplate, + precompileTemplate, templateOnlyComponent, setModifierManager, modifierCapabilities, @@ -45,7 +45,7 @@ QUnit.module('@glimmer/ssr modifiers', () => { const Component = templateOnlyComponent(); setComponentTemplate( - createTemplate({ modifier: Modifier }, '

hello world

'), + precompileTemplate({ modifier: Modifier }, '

hello world

'), Component ); diff --git a/packages/@glimmer/ssr/test/render-options-tests.ts b/packages/@glimmer/ssr/test/render-options-tests.ts index e0c503fb5..93b1a0b11 100644 --- a/packages/@glimmer/ssr/test/render-options-tests.ts +++ b/packages/@glimmer/ssr/test/render-options-tests.ts @@ -1,5 +1,5 @@ import Component from '@glimmer/component'; -import { setComponentTemplate, createTemplate } from '@glimmer/core'; +import { setComponentTemplate, precompileTemplate } from '@glimmer/core'; import HTMLSerializer from '@simple-dom/serializer'; import voidMap from '@simple-dom/void-map'; import { SerializableNode } from '@simple-dom/interface'; @@ -17,7 +17,7 @@ QUnit.module('@glimmer/ssr rendering', () => { const options: RenderOptions = { serializer: new CustomHTMLSerializer(voidMap) }; - setComponentTemplate(createTemplate(`

Hello World

`), MyComponent); + setComponentTemplate(precompileTemplate(`

Hello World

`), MyComponent); const output = await renderToString(MyComponent, options); @@ -26,7 +26,7 @@ QUnit.module('@glimmer/ssr rendering', () => { QUnit.test('setting rehydrate option outputs the block stacks', async (assert) => { class MyComponent extends Component {} - setComponentTemplate(createTemplate(`

Hello World

`), MyComponent); + setComponentTemplate(precompileTemplate(`

Hello World

`), MyComponent); const output = await renderToString(MyComponent, { rehydrate: true }); assert.equal( diff --git a/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/index.js b/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/index.js index 7a55f4d27..ba9c9ce7b 100644 --- a/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/index.js +++ b/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/index.js @@ -17,10 +17,10 @@ module.exports = function strictTemplatePrecompile(babel, options) { const importedName = path.node.imported.name; const localName = path.node.local.name; - if (importedName === 'createTemplate') { + if (importedName === 'precompileTemplate') { state.templateImportId = localName; - // remove the createTemplate named import + // remove the precompileTemplate named import if (path.parentPath.node.specifiers.length > 1) { path.remove(); } else { @@ -35,7 +35,7 @@ module.exports = function strictTemplatePrecompile(babel, options) { } if (path.node.arguments.length === 0 || path.node.arguments.length > 2) { - throw new Error('`createTemplate()` must receive exactly one or two arguments'); + throw new Error('`precompileTemplate()` must receive exactly one or two arguments'); } let scopePath, templatePath; @@ -52,7 +52,7 @@ module.exports = function strictTemplatePrecompile(babel, options) { if (scopePath) { if (scopePath.type !== 'ObjectExpression') { throw new Error( - `createTemplate() must receive an object literal with all of the imported values for the template as its scope parameter, received: ${scopePath.type}` + `precompileTemplate() must receive an object literal with all of the imported values for the template as its scope parameter, received: ${scopePath.type}` ); } @@ -69,7 +69,7 @@ module.exports = function strictTemplatePrecompile(babel, options) { if (type === 'TemplateLiteral') { if (templatePath.node.quasis.length > 1 || templatePath.node.expressions.length > 0) { throw new Error( - 'template strings passed to the `createTemplate()` function may not have any dynamic segments' + 'template strings passed to the `precompileTemplate()` function may not have any dynamic segments' ); } @@ -82,7 +82,7 @@ module.exports = function strictTemplatePrecompile(babel, options) { path.replaceWith(ast.program.body[0].expression); } else { - throw new Error(`createTemplate() must receive a template string, received: ${type}`); + throw new Error(`precompileTemplate() must receive a template string, received: ${type}`); } }, }, diff --git a/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures-options/errors/non-existent-component/code.js b/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures-options/errors/non-existent-component/code.js index 93aa35a8c..847574746 100644 --- a/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures-options/errors/non-existent-component/code.js +++ b/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures-options/errors/non-existent-component/code.js @@ -1,3 +1,3 @@ -import { createTemplate } from '@glimmer/core'; +import { precompileTemplate } from '@glimmer/core'; -createTemplate(``); +precompileTemplate(``); diff --git a/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures-options/precompile/ast-transform/code.js b/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures-options/precompile/ast-transform/code.js index 65dd9ac17..65a075b8e 100644 --- a/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures-options/precompile/ast-transform/code.js +++ b/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures-options/precompile/ast-transform/code.js @@ -1,3 +1,3 @@ -import { createTemplate } from '@glimmer/core'; +import { precompileTemplate } from '@glimmer/core'; -createTemplate('{{bad}}

Hello world

'); +precompileTemplate('{{bad}}

Hello world

'); diff --git a/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/custom-imports/code.js b/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/custom-imports/code.js index 6316d0486..be0052a4f 100644 --- a/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/custom-imports/code.js +++ b/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/custom-imports/code.js @@ -1,4 +1,4 @@ -import { createTemplate as foo } from '@glimmer/core'; +import { precompileTemplate as foo } from '@glimmer/core'; import Component from './component'; foo({ Component }, ``); diff --git a/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/first-parameter/code.js b/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/first-parameter/code.js index 61a297625..c213e144e 100644 --- a/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/first-parameter/code.js +++ b/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/first-parameter/code.js @@ -1,5 +1,5 @@ -import { createTemplate } from '@glimmer/core'; +import { precompileTemplate } from '@glimmer/core'; -createTemplate(`

Hello World

`); +precompileTemplate(`

Hello World

`); -createTemplate('

Hello World

'); +precompileTemplate('

Hello World

'); diff --git a/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/rename-scope-variable/code.js b/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/rename-scope-variable/code.js index 9fecc88b8..d83760a6a 100644 --- a/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/rename-scope-variable/code.js +++ b/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/rename-scope-variable/code.js @@ -1,4 +1,4 @@ -import { createTemplate } from '@glimmer/core'; +import { precompileTemplate } from '@glimmer/core'; import Component from './component'; -createTemplate({ MyComponent: Component }, ``); +precompileTemplate({ MyComponent: Component }, ``); diff --git a/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/second-parameter/code.js b/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/second-parameter/code.js index f7e23614c..d0e2e563e 100644 --- a/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/second-parameter/code.js +++ b/packages/babel-plugins/@glimmer/babel-plugin-strict-template-precompile/test/fixtures/second-parameter/code.js @@ -1,6 +1,6 @@ -import { createTemplate } from '@glimmer/core'; +import { precompileTemplate } from '@glimmer/core'; import Component from './component'; -createTemplate({ Component }, ``); +precompileTemplate({ Component }, ``); -createTemplate({ Component }, ''); +precompileTemplate({ Component }, ''); diff --git a/packages/example-apps/basic/src/MyComponent.ts b/packages/example-apps/basic/src/MyComponent.ts index 4ffcae4d5..834f0546d 100644 --- a/packages/example-apps/basic/src/MyComponent.ts +++ b/packages/example-apps/basic/src/MyComponent.ts @@ -1,7 +1,7 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { - createTemplate, + precompileTemplate, setComponentTemplate, getOwner, templateOnlyComponent, @@ -27,7 +27,7 @@ const isCJK = helper(function (_args, _hash, services) { }); const TemplateOnlyComponent = setComponentTemplate( - createTemplate(`

I am rendered by a template only component: {{@name}}

`), + precompileTemplate(`

I am rendered by a template only component: {{@name}}

`), templateOnlyComponent() ); @@ -46,7 +46,7 @@ class MyComponent extends Component { } setComponentTemplate( - createTemplate( + precompileTemplate( { OtherComponent, TemplateOnlyComponent, myHelper, isCJK, on }, `

Hello {{this.message}}


diff --git a/packages/example-apps/basic/src/OtherComponent.ts b/packages/example-apps/basic/src/OtherComponent.ts index 2bbf37a14..044a64035 100644 --- a/packages/example-apps/basic/src/OtherComponent.ts +++ b/packages/example-apps/basic/src/OtherComponent.ts @@ -1,6 +1,6 @@ import Component from '@glimmer/component'; -import { createTemplate, setComponentTemplate } from '@glimmer/core'; +import { precompileTemplate, setComponentTemplate } from '@glimmer/core'; export default class OtherComponent extends Component {} -setComponentTemplate(createTemplate(`Counter Val: {{@count}}`), OtherComponent); +setComponentTemplate(precompileTemplate(`Counter Val: {{@count}}`), OtherComponent); diff --git a/packages/example-apps/partial-rehydration/src/RehydratableCounter.ts b/packages/example-apps/partial-rehydration/src/RehydratableCounter.ts index 9fd23e703..df20badcb 100644 --- a/packages/example-apps/partial-rehydration/src/RehydratableCounter.ts +++ b/packages/example-apps/partial-rehydration/src/RehydratableCounter.ts @@ -1,6 +1,6 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; -import { createTemplate, setComponentTemplate } from '@glimmer/core'; +import { precompileTemplate, setComponentTemplate } from '@glimmer/core'; import { on, action } from '@glimmer/modifier'; import RehydratableRegion from './RehydratableRegion'; @@ -13,7 +13,7 @@ class RehydratableCounter extends Component { } setComponentTemplate( - createTemplate( + precompileTemplate( { on, RehydratableRegion }, `

{{@message}}

diff --git a/packages/example-apps/partial-rehydration/src/RehydratableRegion.ts b/packages/example-apps/partial-rehydration/src/RehydratableRegion.ts index 425fc5706..abf31a456 100644 --- a/packages/example-apps/partial-rehydration/src/RehydratableRegion.ts +++ b/packages/example-apps/partial-rehydration/src/RehydratableRegion.ts @@ -1,11 +1,11 @@ -import { createTemplate, setComponentTemplate, templateOnlyComponent } from '@glimmer/core'; +import { precompileTemplate, setComponentTemplate, templateOnlyComponent } from '@glimmer/core'; function toJSON(args): string { return JSON.stringify(args); } export default setComponentTemplate( - createTemplate( + precompileTemplate( { toJSON }, `
diff --git a/packages/example-apps/partial-rehydration/src/StaticComponent.ts b/packages/example-apps/partial-rehydration/src/StaticComponent.ts index a4ca2d770..26b27e5ea 100644 --- a/packages/example-apps/partial-rehydration/src/StaticComponent.ts +++ b/packages/example-apps/partial-rehydration/src/StaticComponent.ts @@ -1,8 +1,8 @@ -import { createTemplate, setComponentTemplate, templateOnlyComponent } from '@glimmer/core'; +import { precompileTemplate, setComponentTemplate, templateOnlyComponent } from '@glimmer/core'; import RehydratableCounter from './RehydratableCounter'; const StaticComponent = setComponentTemplate( - createTemplate( + precompileTemplate( { RehydratableCounter }, `

Hello I am a static component. I don't change after page load.

diff --git a/packages/example-apps/rehydration/src/MyComponent.ts b/packages/example-apps/rehydration/src/MyComponent.ts index a9dc48859..933d68bbd 100644 --- a/packages/example-apps/rehydration/src/MyComponent.ts +++ b/packages/example-apps/rehydration/src/MyComponent.ts @@ -1,6 +1,6 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; -import { createTemplate, setComponentTemplate } from '@glimmer/core'; +import { precompileTemplate, setComponentTemplate } from '@glimmer/core'; import { on, action } from '@glimmer/modifier'; class MyComponent extends Component { @@ -12,7 +12,7 @@ class MyComponent extends Component { } setComponentTemplate( - createTemplate( + precompileTemplate( { on }, `

You have clicked the button {{this.count}} times.