From c32ca4bac6317c6e539a1edea059d345508a22ca Mon Sep 17 00:00:00 2001 From: Chris Garrett Date: Wed, 24 Mar 2021 13:22:10 -0700 Subject: [PATCH] Update Glimmer.js to the latest Updates Glimmer.js to the latest, and also updates a number of APIs: \## Breaking Changes - Removes `@glimmerx/babel-plugin-component-templates`, replaces it with `@glimmerx/babel-preset` which wraps `@glimmer/babel-preset`. This uses `babel-plugin-htmlbars-inline-precompile`, which is the same inline precompiler used by Ember.js now, so we are synced between the two frameworks. - Removes support for Ember < 3.25, `@glimmerx/component` will only work with versions of Ember that support strict mode. - Adds `@glimmerx/webpack-loader`, which is now required to run before the Babel loader. - Removes `TemplateArgs` export as a type. \## Other Changes - Adds support for `.gts` and `.gjs` - Re-exports `fn` and `on` from Ember for usage in the Ember version of the addons - Implements `helper()` for use in defining helpers in Ember --- .eslintignore | 8 +- .eslintrc.js | 39 +- .github/workflows/ci.yml | 2 +- .prettierignore | 2 +- README.md | 6 +- package.json | 9 +- .../babel-plugin-component-templates/index.js | 369 ----- .../package.json | 31 - .../class-declaration/code.js | 5 - .../class-declaration/output.js | 10 - .../class-expression/code.js | 5 - .../class-expression/output.js | 8 - .../template-only-component/code.js | 6 - .../template-only-component/output.js | 16 - .../fixtures-compat/class-declaration/code.js | 5 - .../class-declaration/output.js | 13 - .../fixtures-compat/class-expression/code.js | 5 - .../class-expression/output.js | 11 - .../template-only-component/code.js | 3 - .../template-only-component/output.js | 11 - .../precompile/ast-transform-hbs/code.js | 3 - .../precompile/ast-transform-hbs/options.js | 27 - .../precompile/ast-transform-hbs/output.js | 10 - .../precompile/ast-transform/code.js | 5 - .../precompile/ast-transform/options.js | 27 - .../precompile/ast-transform/output.js | 12 - .../precompile/custom/code.js | 5 - .../precompile/custom/options.js | 8 - .../precompile/custom/output.js | 6 - .../test/fixtures/class-declaration/code.js | 8 - .../test/fixtures/class-declaration/output.js | 16 - .../test/fixtures/class-expression/code.js | 5 - .../test/fixtures/class-expression/output.js | 10 - .../test/fixtures/custom-imports/code.js | 23 - .../test/fixtures/custom-imports/options.json | 8 - .../test/fixtures/custom-imports/output.js | 47 - .../test/fixtures/ember/code.js | 8 - .../test/fixtures/ember/options.json | 3 - .../test/fixtures/ember/output.js | 16 - .../test/fixtures/glimmer-env/.babelrc | 5 - .../test/fixtures/glimmer-env/code.js | 14 - .../test/fixtures/glimmer-env/output.js | 21 - .../multiple-classes-commonjs/.babelrc | 5 - .../multiple-classes-commonjs/code.js | 21 - .../multiple-classes-commonjs/output.js | 41 - .../.babelrc | 5 - .../code.js | 11 - .../output.js | 29 - .../test/fixtures/multiple-classes/code.js | 21 - .../test/fixtures/multiple-classes/output.js | 38 - .../test/fixtures/multiscope-tokens/code.js | 16 - .../test/fixtures/multiscope-tokens/output.js | 15 - .../test/fixtures/nested-classes/code.js | 12 - .../test/fixtures/nested-classes/output.js | 24 - .../test/fixtures/phantom-scope/code.js | 8 - .../test/fixtures/phantom-scope/output.js | 14 - .../precompile-disabled-commonjs/.babelrc | 5 - .../precompile-disabled-commonjs/code.js | 11 - .../precompile-disabled-commonjs/options.json | 5 - .../precompile-disabled-commonjs/output.js | 20 - .../fixtures/precompile-disabled-hbs/code.js | 6 - .../precompile-disabled-hbs/options.json | 5 - .../precompile-disabled-hbs/output.js | 13 - .../test/fixtures/precompile-disabled/code.js | 11 - .../fixtures/precompile-disabled/options.json | 5 - .../fixtures/precompile-disabled/output.js | 15 - .../private-local-declarations/code.js | 13 - .../private-local-declarations/output.js | 26 - .../test/fixtures/scoped-tokens-hbs/code.js | 17 - .../test/fixtures/scoped-tokens-hbs/output.js | 13 - .../test/fixtures/scoped-tokens/code.js | 19 - .../test/fixtures/scoped-tokens/output.js | 15 - .../code.js | 9 - .../output.js | 16 - .../test/fixtures/template-only-hbs/code.js | 9 - .../test/fixtures/template-only-hbs/output.js | 15 - .../test/fixtures/typescript/.babelrc | 5 - .../test/fixtures/typescript/code.ts | 13 - .../test/fixtures/typescript/output.ts | 17 - .../test/index.js | 88 -- packages/@glimmerx/babel-preset/index.js | 30 + packages/@glimmerx/babel-preset/package.json | 25 + .../babel-preset/test/fixtures/debug/.babelrc | 5 + .../babel-preset/test/fixtures/debug/code.js | 18 + .../test/fixtures/debug/output.js | 50 + .../test/fixtures/production/.babelrc | 5 + .../test/fixtures/production/code.js | 18 + .../test/fixtures/production/output.js | 50 + packages/@glimmerx/babel-preset/test/index.js | 19 + packages/@glimmerx/blueprint/files/.babelrc | 3 + .../@glimmerx/blueprint/files/.babelrc.js | 11 - .../@glimmerx/blueprint/files/package.json | 16 +- .../blueprint/files/src/{App.js => App.gjs} | 6 +- .../@glimmerx/blueprint/files/tests/util.ts | 3 +- .../blueprint/files/webpack.config.js | 72 + packages/@glimmerx/blueprint/package.json | 2 +- .../@glimmerx/component/ember-addon-main.js | 65 +- packages/@glimmerx/component/package.json | 12 +- packages/@glimmerx/core/index.ts | 3 +- packages/@glimmerx/core/package.json | 6 +- .../core/src/functional-helper-manager.ts | 2 +- .../core/src/functional-modifier-manager.ts | 6 +- packages/@glimmerx/core/src/owner.ts | 2 +- .../@glimmerx/core/src/renderComponent.ts | 2 +- .../@glimmerx/core/tests/modifier-tests.ts | 5 +- packages/@glimmerx/core/tests/render-tests.ts | 10 +- .../eslint-plugin/lib/rules/template-vars.js | 15 +- packages/@glimmerx/eslint-plugin/package.json | 4 +- .../@glimmerx/helper/addon/-private/helper.js | 47 +- packages/@glimmerx/helper/addon/index.js | 7 +- packages/@glimmerx/helper/package.json | 6 +- packages/@glimmerx/helper/src/helper.ts | 20 +- packages/@glimmerx/modifier/addon/index.js | 7 +- packages/@glimmerx/modifier/package.json | 6 +- packages/@glimmerx/service/index.ts | 2 +- packages/@glimmerx/service/package.json | 3 +- packages/@glimmerx/service/src/decorator.ts | 10 +- packages/@glimmerx/ssr/package.json | 4 +- packages/@glimmerx/ssr/src/render.ts | 4 +- .../ssr/tests/render-options-tests.ts | 10 +- packages/@glimmerx/storybook/package.json | 6 +- .../src/server/framework-preset-glimmer.ts | 72 +- packages/@glimmerx/webpack-loader/index.js | 68 + .../@glimmerx/webpack-loader/package.json | 32 + .../{simple-button.js => simple-button.gjs} | 6 +- .../examples/basic-addon/config/ember-try.js | 4 +- packages/examples/basic-addon/package.json | 8 +- packages/examples/basic/.storybook/main.js | 2 +- packages/examples/basic/index.ts | 2 + packages/examples/basic/package.json | 2 +- packages/examples/basic/src/GtsComponent.gts | 7 + .../examples/basic/src/MyComponent.stories.ts | 2 + packages/examples/basic/src/MyComponent.ts | 14 +- ....stories.ts => OtherComponent.stories.gts} | 4 +- packages/examples/ember-app/package.json | 8 +- .../examples/partial-rehydration/server.ts | 2 +- packages/examples/playground/.babelrc | 3 + packages/examples/playground/.babelrc.js | 11 - packages/examples/playground/package.json | 15 +- packages/examples/playground/src/App.ts | 2 +- packages/examples/playground/src/Editor.ts | 2 +- packages/examples/playground/src/index.ts | 2 +- .../examples/playground/src/utils/compile.ts | 16 +- .../playground/src/utils/eval-snippet.ts | 2 +- packages/examples/playground/tests/util.ts | 2 +- .../examples/playground/webpack.config.js | 9 +- packages/examples/rehydration/server.ts | 2 +- tsconfig.json | 2 +- webpack.config.js | 58 +- yarn.lock | 1246 +++++++++++++---- 150 files changed, 1713 insertions(+), 1971 deletions(-) delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/index.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/package.json delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-declaration/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-declaration/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-expression/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-expression/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/template-only-component/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/template-only-component/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-declaration/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-declaration/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-expression/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-expression/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/template-only-component/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/template-only-component/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform-hbs/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform-hbs/options.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform-hbs/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform/options.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/custom/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/custom/options.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/custom/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-declaration/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-declaration/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-expression/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-expression/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/custom-imports/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/custom-imports/options.json delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/custom-imports/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/ember/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/ember/options.json delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/ember/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/glimmer-env/.babelrc delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/glimmer-env/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/glimmer-env/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-commonjs/.babelrc delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-commonjs/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-commonjs/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-same-scope-var-commonjs/.babelrc delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-same-scope-var-commonjs/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-same-scope-var-commonjs/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiscope-tokens/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiscope-tokens/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/nested-classes/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/nested-classes/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/phantom-scope/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/phantom-scope/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/.babelrc delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/options.json delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-hbs/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-hbs/options.json delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-hbs/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled/options.json delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/private-local-declarations/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/private-local-declarations/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens-hbs/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens-hbs/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs-with-component-import/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs-with-component-import/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs/code.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs/output.js delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/typescript/.babelrc delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/typescript/code.ts delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/fixtures/typescript/output.ts delete mode 100644 packages/@glimmerx/babel-plugin-component-templates/test/index.js create mode 100644 packages/@glimmerx/babel-preset/index.js create mode 100644 packages/@glimmerx/babel-preset/package.json create mode 100644 packages/@glimmerx/babel-preset/test/fixtures/debug/.babelrc create mode 100644 packages/@glimmerx/babel-preset/test/fixtures/debug/code.js create mode 100644 packages/@glimmerx/babel-preset/test/fixtures/debug/output.js create mode 100644 packages/@glimmerx/babel-preset/test/fixtures/production/.babelrc create mode 100644 packages/@glimmerx/babel-preset/test/fixtures/production/code.js create mode 100644 packages/@glimmerx/babel-preset/test/fixtures/production/output.js create mode 100644 packages/@glimmerx/babel-preset/test/index.js create mode 100644 packages/@glimmerx/blueprint/files/.babelrc delete mode 100644 packages/@glimmerx/blueprint/files/.babelrc.js rename packages/@glimmerx/blueprint/files/src/{App.js => App.gjs} (81%) create mode 100644 packages/@glimmerx/blueprint/files/webpack.config.js create mode 100644 packages/@glimmerx/webpack-loader/index.js create mode 100644 packages/@glimmerx/webpack-loader/package.json rename packages/examples/basic-addon/addon/components/{simple-button.js => simple-button.gjs} (69%) create mode 100644 packages/examples/basic/src/GtsComponent.gts rename packages/examples/basic/src/{OtherComponent.stories.ts => OtherComponent.stories.gts} (68%) create mode 100644 packages/examples/playground/.babelrc delete mode 100644 packages/examples/playground/.babelrc.js diff --git a/.eslintignore b/.eslintignore index efc19ddc..c2f4d856 100644 --- a/.eslintignore +++ b/.eslintignore @@ -10,7 +10,7 @@ **/bower_components/** # Fixtures -**/packages/@glimmerx/babel-plugin-component-templates/test/**/code.js -**/packages/@glimmerx/babel-plugin-component-templates/test/**/output.js -**/packages/@glimmerx/babel-plugin-component-templates/test/**/code.ts -**/packages/@glimmerx/babel-plugin-component-templates/test/**/output.ts +**/packages/@glimmerx/babel-preset/test/**/code.js +**/packages/@glimmerx/babel-preset/test/**/output.js +**/packages/@glimmerx/babel-preset/test/**/code.ts +**/packages/@glimmerx/babel-preset/test/**/output.ts diff --git a/.eslintrc.js b/.eslintrc.js index 9003e132..9171fa82 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,6 +5,9 @@ module.exports = { ecmaVersion: 2019, sourceType: 'module', }, + env: { + es6: true, + }, extends: [ 'eslint:recommended', 'plugin:prettier/recommended', @@ -30,7 +33,6 @@ module.exports = { '**/scripts/**/*.js', '**/blueprints/**/*.js', 'webpack.config.js', - 'packages/babel-plugins/**/*.js', 'packages/@glimmerx/blueprint/index.js', ], env: { @@ -40,19 +42,9 @@ module.exports = { }, { files: [ - 'packages/@glimmerx/babel-plugin-component-templates/**/*.js', + 'packages/@glimmerx/babel-preset/**/*.js', 'packages/@glimmerx/eslint-plugin/**/*.js', - ], - env: { - es6: true, - node: true, - mocha: true, - }, - }, - { - files: [ - 'packages/@glimmerx/babel-plugin-component-templates/test/**/code.js', - 'packages/@glimmerx/babel-plugin-component-templates/test/**/output.js', + 'packages/@glimmerx/webpack-loader/**/*.js', ], env: { es6: true, @@ -67,17 +59,6 @@ module.exports = { 'no-process-exit': 'off', }, }, - // source Js - { - files: ['**/src/**/*.js', '**/test/**/*.js'], - env: { - es2020: true, - browser: true, - }, - parserOptions: { - sourceType: 'module', - }, - }, // TypeScript source { files: ['**/*.ts'], @@ -91,9 +72,19 @@ module.exports = { '@typescript-eslint/explicit-function-return-type': 'error', '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], + '@typescript-eslint/ban-types': ['error', { + types: { + // we currently use `object` as "valid WeakMap key" in a lot of APIs + object: false, + } + }], + // We should try to remove this eventually '@typescript-eslint/explicit-function-return-type': 'off', + // We should also try to remove this eventually + '@typescript-eslint/ban-ts-ignore': 'off', + // disabling this one because of DEBUG APIs, if we ever find a better // way to suport those we should re-enable it '@typescript-eslint/no-non-null-assertion': 'off', diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95ae07c3..3963f089 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: strategy: matrix: - ember-version: [default, release, beta, canary, lts-3.16] + ember-version: [default, release, beta, canary, "3.25"] steps: - uses: actions/checkout@v2 diff --git a/.prettierignore b/.prettierignore index a5987a63..dc5198e9 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1 @@ -packages/@glimmerx/babel-plugin-component-templates/test/ \ No newline at end of file +packages/@glimmerx/babel-preset/test/ diff --git a/README.md b/README.md index ee299bb0..132857ad 100644 --- a/README.md +++ b/README.md @@ -54,11 +54,11 @@ npm: yarn add @glimmerx/core @glimmerx/component ``` -You will also need to install a Babel plugin that compiles templates with the -Glimmer compiler: +You will also need to install a Babel preset that handles Glimmer templates and +other language features, such as decorators and class fields: ``` -yarn add -D @glimmerx/babel-plugin-component-templates +yarn add -D @glimmerx/babel-preset ``` If using ESLint, you will also want to install / use the plugin provided, as the `no-unused-vars` core rule will fail without it diff --git a/package.json b/package.json index b132d515..19a40e53 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "start": "webpack-dev-server", "storybook": "yarn build && yarn workspace basic-example-app storybook", "test": "yarn lint && testem ci && yarn test:babel-plugins", - "test:babel-plugins": "mocha -r esm --timeout 5000 packages/@glimmerx/babel-plugin-component-templates/test packages/@glimmerx/eslint-plugin/test/lib/rules", + "test:babel-plugins": "mocha -r esm --timeout 5000 packages/@glimmerx/babel-preset/test packages/@glimmerx/eslint-plugin/test/lib/rules", "test:ember": "yarn workspace basic-addon ember try:one", "test:playground": "yarn workspace glimmerx-playground test", "test:watch": "testem" @@ -44,10 +44,9 @@ "@babel/plugin-proposal-decorators": "^7.8.3", "@babel/preset-env": "^7.9.5", "@babel/preset-typescript": "^7.9.0", - "@glimmer/babel-plugin-glimmer-env": "2.0.0-beta.12", "@types/qunit": "^2.9.1", - "@typescript-eslint/eslint-plugin": "^2.27.0", - "@typescript-eslint/parser": "^2.27.0", + "@typescript-eslint/eslint-plugin": "^4.18.0", + "@typescript-eslint/parser": "^4.18.0", "babel-loader": "^8.0.6", "eslint": "^6.8.0", "eslint-config-prettier": "^6.10.1", @@ -62,7 +61,7 @@ "testem": "^3.0.3", "ts-loader": "^6.2.2", "tsconfig-paths-webpack-plugin": "^3.2.0", - "typescript": "~3.8.3", + "typescript": "~4.2.3", "webpack": "^4.42.1", "webpack-cli": "^3.3.11", "webpack-dev-server": "^3.10.3" diff --git a/packages/@glimmerx/babel-plugin-component-templates/index.js b/packages/@glimmerx/babel-plugin-component-templates/index.js deleted file mode 100644 index a90a0cf0..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/index.js +++ /dev/null @@ -1,369 +0,0 @@ -const glimmerPrecompileTemplate = require('@glimmer/babel-plugin-strict-template-precompile') - .precompileTemplate; -const { addNamed } = require('@babel/helper-module-imports'); -const { traverse, preprocess } = require('@glimmer/syntax'); -const { precompile } = require('@glimmer/compiler'); - -/* AST.Node reference: https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/syntax/lib/types/nodes.ts#L268 */ - -/** - * Gets the correct Token from the Node based on it's type - * @param {AST.Node} node - the node to extract tokens from - * @param {string[]} scopedTokens - An array of scoped tokens - * @returns {string} A tag to add to the list of tokens - */ -function tokensFromType(node, scopedTokens) { - const tokensMap = { - PathExpression: (node) => { - if (node.data === true || node.this === true) { - return; - } - const [possbleToken] = node.parts; - if (!scopedTokens.includes(possbleToken)) { - return possbleToken; - } - }, - ElementNode: ({ tag }) => { - const char = tag.charAt(0); - if (char !== char.toUpperCase() || char === ':') { - return; - } - if (scopedTokens.includes(tag)) { - return; - } - return tag; - }, - }; - if (node.type in tokensMap) { - return tokensMap[node.type](node); - } -} - -/** - * Adds tokens to the tokensSet based on their node.type - * - * @param {Set} tokensSet The current Set of unique tokens - * @param {AST.Node} node - the node to extract tokens from - * @param {string | string[]} scopedTokens - a list, or single string of tokens - * @param {string[]} [nativeTokens] - An optional param of nativeTokens to exclude from the list (ex. ['if', 'each']) - */ -function addTokens(tokensSet, node, scopedTokens, nativeTokens = []) { - const maybeTokens = tokensFromType(node, scopedTokens); - (Array.isArray(maybeTokens) ? maybeTokens : [maybeTokens]).forEach((maybeToken) => { - if ( - maybeToken !== undefined && - !nativeTokens.includes(maybeToken) && - !maybeToken.startsWith('@') - ) { - tokensSet.add(maybeToken); - } - }); -} - -/** - * Parses and traverses a given handlebars html template to extract all tokens referenced - * that will come from the parent scope - * - * @param {string} html The handlebars html to process into an AST and traverse - * @param {string[]} [nativeTokens] - An optional param of nativeTokens to exclude from the list (ex. ['if', 'each']) - * @returns {string[]} The list of token names - */ -function getTemplateTokens(html, nativeTokens) { - const ast = preprocess(html); - const tokensSet = new Set(); - const scopedTokens = []; - - traverse(ast, { - Block: { - enter({ blockParams }) { - blockParams.forEach((param) => { - scopedTokens.push(param); - }); - }, - exit({ blockParams }) { - blockParams.forEach(() => { - scopedTokens.pop(); - }); - }, - }, - ElementNode: { - enter(node) { - node.blockParams.forEach((param) => { - scopedTokens.push(param); - }); - addTokens(tokensSet, node, scopedTokens); - }, - exit({ blockParams }) { - blockParams.forEach(() => { - scopedTokens.pop(); - }); - }, - }, - All(node) { - addTokens(tokensSet, node, scopedTokens, nativeTokens); - }, - }); - return Array.from(tokensSet); -} - -module.exports = function (babel, options) { - const { types: t, parse } = babel; - const { - // Whether or not we'ret targeting Ember. If so, we use the Ember global - // instead of adding imports, and we use different default import paths. - ember = false, - - setTemplatePath = '@glimmer/core', - setTemplateName = ember ? '_setComponentTemplate' : 'setComponentTemplate', - - createTemplatePath = '@glimmer/core', - createTemplateName = 'createTemplate', - - templateOnlyComponentPath = '@glimmer/core', - templateOnlyComponentName = ember ? '_templateOnlyComponent' : 'templateOnlyComponent', - - precompile: precompileOptions = {}, - - // Users can pass a custom precompile function. This is used by Ember. - precompileTemplate = glimmerPrecompileTemplate, - } = options || {}; - - const shouldPrecompile = precompileOptions.disabled !== true; - - function maybeAddImport(state, programPath, name, importPath) { - let stateKey = `__import__${name}`; - - if (!state[stateKey]) { - if (ember) { - // In Ember, we destructure the value from the Ember global - const globalImport = t.variableDeclaration('var', [ - t.variableDeclarator( - t.identifier(name), - t.memberExpression(t.identifier('Ember'), t.identifier(name)) - ), - ]); - - programPath.get('body.0').insertBefore(globalImport); - - state[stateKey] = name; - } else { - state[stateKey] = addNamed(programPath, name, importPath, { - importedType: 'es6', - }).name; - } - } - - return state[stateKey]; - } - - function maybeAddSetTemplateImport(state, programPath) { - return maybeAddImport(state, programPath, setTemplateName, setTemplatePath); - } - - function maybeAddCreateTemplateImport(state, programPath) { - return maybeAddImport(state, programPath, createTemplateName, createTemplatePath); - } - - function maybeAddTemplateOnlyComponentImport(state, programPath) { - return maybeAddImport(state, programPath, templateOnlyComponentName, templateOnlyComponentPath); - } - - return { - name: '@glimmerx/babel-plugin-component-templates', - manipulateOptions({ parserOpts }) { - parserOpts.plugins.push(['classProperties']); - }, - visitor: { - // This visitor exists to add an extra reference to all template bindings - // so they don't get removed eagerly. This is because we may end up using - // them later on and adding a reference ourselves. - Program: { - enter(path, state) { - const parentScope = path.scope.getProgramParent(); - - // Get the bindings and filter out any that are typescript types - const bindings = Object.values(parentScope.bindings).filter( - (b) => !b.referencePaths.some((p) => p.parent.type === 'TSTypeReference') - ); - - if (bindings.length === 0) return; - - // create a new empty node to add a reference to in the binding - let firstNode = path.get('body.0'); - firstNode.insertBefore(t.noop()); - firstNode = path.get('body.0'); - - bindings.forEach((b) => b.reference(firstNode)); - - // save the node and original bindings off to remove on exit - state.originalBindings = bindings; - state.emptyPath = firstNode; - }, - - exit(path, state) { - if (state.originalBindings) { - // dereference all the original bindings, and remove the empty path - state.originalBindings.forEach((b) => b.dereference(state.emptyPath)); - state.emptyPath.remove(); - } - }, - }, - - ImportDefaultSpecifier(path, state) { - if (state.glimmerComponentImportId || path.parent.source.value !== '@glimmerx/component') { - return; - } - const localName = path.node.local.name; - state.glimmerComponentImportId = localName; - }, - - ImportSpecifier(path, state) { - if (state.hbsImportId || path.parent.source.value !== '@glimmerx/component') { - return; - } - const importedName = path.node.imported.name; - const localName = path.node.local.name; - if (importedName === 'hbs') { - state.hbsImportId = localName; - // remove the hbs named import - if (path.parentPath.node.specifiers.length > 1) { - path.remove(); - } else { - path.parentPath.remove(); - } - } - }, - - ClassExpression(path, state) { - const classBody = path.get('body').get('body'); - const templateProp = findTemplateProperty(classBody, state.hbsImportId); - - if (templateProp) { - insertTemplateWrapper(path.scope.getProgramParent().path, path, templateProp, state); - templateProp.remove(); - } - }, - - ClassDeclaration(path, state) { - const classBody = path.get('body').get('body'); - const templateProp = findTemplateProperty(classBody, state.hbsImportId); - - if (templateProp) { - insertTemplateWrapper(path.scope.getProgramParent().path, path, templateProp, state); - templateProp.remove(); - } - }, - - TaggedTemplateExpression(path, state) { - if (path.node.tag.name !== state.hbsImportId) { - return; - } - - let programPath = path.scope.getProgramParent().path; - - const setTemplateId = maybeAddSetTemplateImport(state, programPath); - const templateOnlyId = maybeAddTemplateOnlyComponentImport(state, programPath); - - const templateNode = shouldPrecompile - ? buildTemplate(path) - : buildCreateTemplate(path, programPath, state); - - path.replaceWith( - t.callExpression(t.identifier(setTemplateId), [ - templateNode, - t.callExpression(t.identifier(templateOnlyId), []), - ]) - ); - }, - }, - }; - - function findTemplateProperty(classBody, hbsImportId) { - return classBody.find((propPath) => { - return ( - propPath.node.static && - propPath.node.key.name === 'template' && - propPath.node.value.type === 'TaggedTemplateExpression' && - propPath.node.value.tag.name === hbsImportId - ); - }); - } - - function insertTemplateWrapper(programPath, classPath, templatePath, state) { - const setTemplateId = maybeAddSetTemplateImport(state, programPath); - - const template = shouldPrecompile - ? buildTemplate(templatePath) - : buildCreateTemplate(templatePath, programPath, state); - - if (classPath.isClassExpression()) { - classPath.replaceWith( - t.callExpression(t.identifier(setTemplateId), [template, classPath.node]) - ); - } else { - const classId = classPath.node.id; - - classPath.insertAfter(t.callExpression(t.identifier(setTemplateId), [template, classId])); - } - } - - function getFilteredTemplateTokens(path, templateSource) { - const templateScopeTokens = getTemplateTokens(templateSource); - - const filtered = []; - templateScopeTokens.forEach((token) => { - const binding = path.scope.getBinding(token); - if (binding) { - binding.reference(path); - filtered.push(binding.identifier.name); - } - }); - - return filtered; - } - - function buildTemplate(path) { - const templateSource = getTemplateString(path); - const templateScopeTokens = getFilteredTemplateTokens(path, templateSource); - - const compiledTemplate = precompileTemplate( - templateSource, - templateScopeTokens, - precompileOptions - ); - - let ast = parse(compiledTemplate); - - return ast.program.body[0].expression; - } - - function buildCreateTemplate(path, programPath, state) { - const createTemplateId = maybeAddCreateTemplateImport(state, programPath); - const templateSource = getTemplateString(path); - const tokens = getFilteredTemplateTokens(path, templateSource); - - const scopeObject = t.objectExpression( - tokens.map((token) => - t.objectProperty(t.identifier(token), t.identifier(token), false, false) - ) - ); - - return t.callExpression(t.identifier(createTemplateId), [ - scopeObject, - t.templateLiteral([t.templateElement({ raw: templateSource })], []), - ]); - } - - function getTemplateString(path) { - const stringNode = path.node.value || path.node; - - if (t.isTaggedTemplateExpression(stringNode)) { - return stringNode.quasi.quasis[0].value.raw; - } - return path.node.value.quasis[0].value.raw; - } -}; - -module.exports.getTemplateTokens = getTemplateTokens; -// Reexport the precompile function from @glimmer/compiler for any other babel plugins so that they have consistent versioning for the compiler -module.exports.precompile = precompile; diff --git a/packages/@glimmerx/babel-plugin-component-templates/package.json b/packages/@glimmerx/babel-plugin-component-templates/package.json deleted file mode 100644 index a9831456..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "@glimmerx/babel-plugin-component-templates", - "version": "0.5.0", - "description": "Compiles Glimmer component templates", - "repository": "https://github.com/glimmerjs/glimmer-experimental", - "author": "Tom Dale ", - "license": "MIT", - "private": false, - "files": [ - "index.js" - ], - "scripts": { - "test": "mocha -r esm" - }, - "dependencies": { - "@babel/core": "^7.9.0", - "@babel/helper-module-imports": "^7.8.3", - "@glimmer/babel-plugin-strict-template-precompile": "2.0.0-beta.12", - "@glimmer/syntax": "0.73.0" - }, - "devDependencies": { - "@babel/preset-env": "^7.9.5", - "babel-plugin-tester": "^6.4.0", - "esm": "^3.2.25", - "mocha": "^7.1.1" - }, - "volta": { - "node": "12.10.0", - "yarn": "1.22.4" - } -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-declaration/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-declaration/code.js deleted file mode 100644 index ba1e6ed7..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-declaration/code.js +++ /dev/null @@ -1,5 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; - -class MyComponent extends Component { - static template = hbs`

{{_t "foo"}}

`; -} \ No newline at end of file diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-declaration/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-declaration/output.js deleted file mode 100644 index a7be0a91..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-declaration/output.js +++ /dev/null @@ -1,10 +0,0 @@ -import { createTemplate as _createTemplate } from "@glimmer/core"; -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import { t as _t } from "t-helper"; -import Component from '@glimmerx/component'; - -class MyComponent extends Component {} - -_setComponentTemplate(_createTemplate({ - _t: _t -}, `

{{_t "foo"}}

`), MyComponent) diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-expression/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-expression/code.js deleted file mode 100644 index e512830e..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-expression/code.js +++ /dev/null @@ -1,5 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; - -const MyComponent = class extends Component { - static template = hbs`

{{_t "foo"}}

`; -} \ No newline at end of file diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-expression/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-expression/output.js deleted file mode 100644 index dfb43ed8..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/class-expression/output.js +++ /dev/null @@ -1,8 +0,0 @@ -import { createTemplate as _createTemplate } from "@glimmer/core"; -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import { t as _t } from "t-helper"; -import Component from '@glimmerx/component'; - -const MyComponent = _setComponentTemplate(_createTemplate({ - _t: _t -}, `

{{_t "foo"}}

`), class extends Component {}); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/template-only-component/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/template-only-component/code.js deleted file mode 100644 index 2644d301..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/template-only-component/code.js +++ /dev/null @@ -1,6 +0,0 @@ -import { hbs } from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -import YetAnotherComponent from './YetAnotherComponent'; - -const template1 = hbs`{{_t "bar"}}

Hello world

`; -const template2 = hbs`{{_t "foo"}}`; \ No newline at end of file diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/template-only-component/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/template-only-component/output.js deleted file mode 100644 index f06fd087..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat-options/template-only-component/output.js +++ /dev/null @@ -1,16 +0,0 @@ -import { createTemplate as _createTemplate } from "@glimmer/core"; -import { templateOnlyComponent as _templateOnlyComponent } from "@glimmer/core"; -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import { t as _t } from "t-helper"; -import OtherComponent from './OtherComponent'; -import YetAnotherComponent from './YetAnotherComponent'; - -const template1 = _setComponentTemplate(_createTemplate({ - _t: _t, - OtherComponent: OtherComponent -}, `{{_t "bar"}}

Hello world

`), _templateOnlyComponent()); - -const template2 = _setComponentTemplate(_createTemplate({ - _t: _t, - YetAnotherComponent: YetAnotherComponent -}, `{{_t "foo"}}`), _templateOnlyComponent()); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-declaration/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-declaration/code.js deleted file mode 100644 index ba1e6ed7..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-declaration/code.js +++ /dev/null @@ -1,5 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; - -class MyComponent extends Component { - static template = hbs`

{{_t "foo"}}

`; -} \ No newline at end of file diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-declaration/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-declaration/output.js deleted file mode 100644 index 22b8c5d2..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-declaration/output.js +++ /dev/null @@ -1,13 +0,0 @@ -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import { t as _t } from "t-helper"; -import Component from '@glimmerx/component'; - -class MyComponent extends Component {} - -_setComponentTemplate({ - "id": "BFMB8fiz", - "block": "[[[10,\"h1\"],[12],[1,[28,[32,0],[\"foo\"],null]],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [_t], - "isStrictMode": true -}, MyComponent) diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-expression/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-expression/code.js deleted file mode 100644 index e512830e..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-expression/code.js +++ /dev/null @@ -1,5 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; - -const MyComponent = class extends Component { - static template = hbs`

{{_t "foo"}}

`; -} \ No newline at end of file diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-expression/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-expression/output.js deleted file mode 100644 index 8f4e311e..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/class-expression/output.js +++ /dev/null @@ -1,11 +0,0 @@ -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import { t as _t } from "t-helper"; -import Component from '@glimmerx/component'; - -const MyComponent = _setComponentTemplate({ - "id": "BFMB8fiz", - "block": "[[[10,\"h1\"],[12],[1,[28,[32,0],[\"foo\"],null]],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [_t], - "isStrictMode": true -}, class extends Component {}); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/template-only-component/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/template-only-component/code.js deleted file mode 100644 index dbb50cbc..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/template-only-component/code.js +++ /dev/null @@ -1,3 +0,0 @@ -import { hbs } from '@glimmerx/component'; - -const someTemplate = hbs`

{{_t "foo"}}

`; \ No newline at end of file diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/template-only-component/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/template-only-component/output.js deleted file mode 100644 index 928c143e..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-compat/template-only-component/output.js +++ /dev/null @@ -1,11 +0,0 @@ -import { templateOnlyComponent as _templateOnlyComponent } from "@glimmer/core"; -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import { t as _t } from "t-helper"; - -const someTemplate = _setComponentTemplate({ - "id": "BFMB8fiz", - "block": "[[[10,\"h1\"],[12],[1,[28,[32,0],[\"foo\"],null]],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [_t], - "isStrictMode": true -}, _templateOnlyComponent()); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform-hbs/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform-hbs/code.js deleted file mode 100644 index a8005ed8..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform-hbs/code.js +++ /dev/null @@ -1,3 +0,0 @@ -import { hbs } from '@glimmerx/component'; - -const template = hbs`{{bad}}

Hello world

`; diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform-hbs/options.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform-hbs/options.js deleted file mode 100644 index 5434570f..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform-hbs/options.js +++ /dev/null @@ -1,27 +0,0 @@ -// babel-plugin-test only supports options as an options.json file, -// so we have to manually pass this through to our fixture. - -const precompileOptions = { - meta: {}, - plugins: { - ast: [ - () => { - return { - name: 'remove-bad-helper', - visitor: { - MustacheStatement(node) { - if (node.path.original == 'bad') { - return null; - } - }, - }, - }; - }, - ], - }, - mode: 'precompile', -}; - -export default { - precompile: precompileOptions, -}; diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform-hbs/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform-hbs/output.js deleted file mode 100644 index f7b573a1..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform-hbs/output.js +++ /dev/null @@ -1,10 +0,0 @@ -import { templateOnlyComponent as _templateOnlyComponent } from "@glimmer/core"; -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; - -const template = _setComponentTemplate({ - "id": "iQBI6eOx", - "block": "[[[10,\"h1\"],[12],[1,\"Hello world\"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}, _templateOnlyComponent()); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform/code.js deleted file mode 100644 index 9d79ffb7..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform/code.js +++ /dev/null @@ -1,5 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; - -class MyComponent extends Component { - static template = hbs`{{bad}}

Hello world

`; -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform/options.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform/options.js deleted file mode 100644 index 5434570f..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform/options.js +++ /dev/null @@ -1,27 +0,0 @@ -// babel-plugin-test only supports options as an options.json file, -// so we have to manually pass this through to our fixture. - -const precompileOptions = { - meta: {}, - plugins: { - ast: [ - () => { - return { - name: 'remove-bad-helper', - visitor: { - MustacheStatement(node) { - if (node.path.original == 'bad') { - return null; - } - }, - }, - }; - }, - ], - }, - mode: 'precompile', -}; - -export default { - precompile: precompileOptions, -}; diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform/output.js deleted file mode 100644 index 58262d0a..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/ast-transform/output.js +++ /dev/null @@ -1,12 +0,0 @@ -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import Component from '@glimmerx/component'; - -class MyComponent extends Component {} - -_setComponentTemplate({ - "id": "iQBI6eOx", - "block": "[[[10,\"h1\"],[12],[1,\"Hello world\"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}, MyComponent) diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/custom/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/custom/code.js deleted file mode 100644 index 9d79ffb7..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/custom/code.js +++ /dev/null @@ -1,5 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; - -class MyComponent extends Component { - static template = hbs`{{bad}}

Hello world

`; -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/custom/options.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/custom/options.js deleted file mode 100644 index bec3a33f..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/custom/options.js +++ /dev/null @@ -1,8 +0,0 @@ -// babel-plugin-test only supports options as an options.json file, -// so we have to manually pass this through to our fixture. - -export default { - precompileTemplate(template) { - return `CUSTOM_COMPILER("${template}")`; - }, -}; diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/custom/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/custom/output.js deleted file mode 100644 index 2f3901b7..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures-options/precompile/custom/output.js +++ /dev/null @@ -1,6 +0,0 @@ -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import Component from '@glimmerx/component'; - -class MyComponent extends Component {} - -_setComponentTemplate(CUSTOM_COMPILER("{{bad}}

Hello world

"), MyComponent) diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-declaration/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-declaration/code.js deleted file mode 100644 index 7758dc83..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-declaration/code.js +++ /dev/null @@ -1,8 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -const unknownValue = null; -const MaybeComponent = null; -const maybeModifier = null; -class MyComponent extends Component { - static template = hbs`

Hello world {{unknownValue}}

`; -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-declaration/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-declaration/output.js deleted file mode 100644 index d8c18ac1..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-declaration/output.js +++ /dev/null @@ -1,16 +0,0 @@ -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import Component from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -const unknownValue = null; -const MaybeComponent = null; -const maybeModifier = null; - -class MyComponent extends Component {} - -_setComponentTemplate({ - "id": "jFBJ3iUu", - "block": "[[[11,\"h1\"],[4,[32,0],null,null],[12],[1,\"Hello world \"],[1,[32,1]],[8,[32,2],null,null,null],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [maybeModifier, unknownValue, MaybeComponent], - "isStrictMode": true -}, MyComponent) diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-expression/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-expression/code.js deleted file mode 100644 index 887393b3..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-expression/code.js +++ /dev/null @@ -1,5 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; - -const MyComponent = class extends Component { - static template = hbs`

Hello world

`; -} \ No newline at end of file diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-expression/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-expression/output.js deleted file mode 100644 index 6ba63592..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/class-expression/output.js +++ /dev/null @@ -1,10 +0,0 @@ -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import Component from '@glimmerx/component'; - -const MyComponent = _setComponentTemplate({ - "id": "UnWFMClF", - "block": "[[[10,\"h1\"],[12],[1,\"Hello world\"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}, class extends Component {}); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/custom-imports/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/custom-imports/code.js deleted file mode 100644 index db3a795f..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/custom-imports/code.js +++ /dev/null @@ -1,23 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; - -class Class1Declaration extends Component { - static template = hbs`

Hello world

`; -} - -const Class1Expression = class extends Component { - static template = hbs`

Hello world

`; -} - -class Class2Declaration extends Component { - static template = hbs`

- Goodbye world -

`; -} - -const Class2Expression = class extends Component { - static template = hbs`

- Goodbye world -

`; -} - -const TOComponent = hbs`

Hello again world

` diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/custom-imports/options.json b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/custom-imports/options.json deleted file mode 100644 index 1fa081f9..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/custom-imports/options.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "setTemplatePath": "@glimmerx/other-package", - "setTemplateName": "dangerouslySetComponentTemplate", - "createTemplatePath": "@glimmerx/some-other-package", - "createTemplateName": "createStrictTemplate", - "templateOnlyComponentPath": "@glimmerx/some-component-path", - "templateOnlyComponentName": "TOComponent" -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/custom-imports/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/custom-imports/output.js deleted file mode 100644 index 527c85fc..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/custom-imports/output.js +++ /dev/null @@ -1,47 +0,0 @@ -import { TOComponent as _TOComponent } from "@glimmerx/some-component-path"; -import { dangerouslySetComponentTemplate as _dangerouslySetComponentTemplate } from "@glimmerx/other-package"; -import Component from '@glimmerx/component'; - -class Class1Declaration extends Component {} - -_dangerouslySetComponentTemplate({ - "id": "UnWFMClF", - "block": "[[[10,\"h1\"],[12],[1,\"Hello world\"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}, Class1Declaration) - -const Class1Expression = _dangerouslySetComponentTemplate({ - "id": "UnWFMClF", - "block": "[[[10,\"h1\"],[12],[1,\"Hello world\"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}, class extends Component {}); - -class Class2Declaration extends Component {} - -_dangerouslySetComponentTemplate({ - "id": "PN1+SdGD", - "block": "[[[10,\"h2\"],[12],[1,\"\\n Goodbye world\\n \"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}, Class2Declaration) - -const Class2Expression = _dangerouslySetComponentTemplate({ - "id": "E/B0dLEA", - "block": "[[[10,\"h2\"],[12],[1,\"\\n Goodbye world\"],[8,[32,0],null,null,null],[1,\"\\n \"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [Class2Declaration], - "isStrictMode": true -}, class extends Component {}); - -const TOComponent = _dangerouslySetComponentTemplate({ - "id": "fyKZX1dI", - "block": "[[[10,\"h3\"],[12],[1,\"Hello again world\"],[8,[32,0],null,null,null],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [Class2Expression], - "isStrictMode": true -}, _TOComponent()); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/ember/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/ember/code.js deleted file mode 100644 index 7758dc83..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/ember/code.js +++ /dev/null @@ -1,8 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -const unknownValue = null; -const MaybeComponent = null; -const maybeModifier = null; -class MyComponent extends Component { - static template = hbs`

Hello world {{unknownValue}}

`; -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/ember/options.json b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/ember/options.json deleted file mode 100644 index 46ff5e82..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/ember/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "ember": true -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/ember/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/ember/output.js deleted file mode 100644 index 842108dc..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/ember/output.js +++ /dev/null @@ -1,16 +0,0 @@ -var _setComponentTemplate = Ember._setComponentTemplate; -import Component from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -const unknownValue = null; -const MaybeComponent = null; -const maybeModifier = null; - -class MyComponent extends Component {} - -_setComponentTemplate({ - "id": "jFBJ3iUu", - "block": "[[[11,\"h1\"],[4,[32,0],null,null],[12],[1,\"Hello world \"],[1,[32,1]],[8,[32,2],null,null,null],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [maybeModifier, unknownValue, MaybeComponent], - "isStrictMode": true -}, MyComponent) diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/glimmer-env/.babelrc b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/glimmer-env/.babelrc deleted file mode 100644 index bf9a68af..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/glimmer-env/.babelrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "plugins": [ - "@glimmer/babel-plugin-glimmer-env" - ] -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/glimmer-env/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/glimmer-env/code.js deleted file mode 100644 index 1175602d..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/glimmer-env/code.js +++ /dev/null @@ -1,14 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -const unknownValue = null; -const MaybeComponent = null; -const maybeModifier = null; -import { DEBUG } from '@glimmer/env'; - -if (DEBUG) { - // do a thing -} - -class MyComponent extends Component { - static template = hbs`

Hello world {{unknownValue}}

`; -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/glimmer-env/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/glimmer-env/output.js deleted file mode 100644 index 3c20b72e..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/glimmer-env/output.js +++ /dev/null @@ -1,21 +0,0 @@ -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import Component from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -const unknownValue = null; -const MaybeComponent = null; -const maybeModifier = null; - -if (true -/* DEBUG */ -) {// do a thing -} - -class MyComponent extends Component {} - -_setComponentTemplate({ - "id": "jFBJ3iUu", - "block": "[[[11,\"h1\"],[4,[32,0],null,null],[12],[1,\"Hello world \"],[1,[32,1]],[8,[32,2],null,null,null],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [maybeModifier, unknownValue, MaybeComponent], - "isStrictMode": true -}, MyComponent) diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-commonjs/.babelrc b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-commonjs/.babelrc deleted file mode 100644 index 65f8b13e..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-commonjs/.babelrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "plugins": [ - "@babel/plugin-transform-modules-commonjs" - ] -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-commonjs/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-commonjs/code.js deleted file mode 100644 index a5850712..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-commonjs/code.js +++ /dev/null @@ -1,21 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; - -class Class1Declaration extends Component { - static template = hbs`

Hello world

`; -} - -const Class1Expression = class extends Component { - static template = hbs`

Hello world

`; -} - -class Class2Declaration extends Component { - static template = hbs`

- Goodbye world -

`; -} - -const Class2Expression = class extends Component { - static template = hbs`

- Goodbye world -

`; -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-commonjs/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-commonjs/output.js deleted file mode 100644 index c102fc07..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-commonjs/output.js +++ /dev/null @@ -1,41 +0,0 @@ -"use strict"; - -var _core = require("@glimmer/core"); - -var _component = _interopRequireDefault(require("@glimmerx/component")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -class Class1Declaration extends _component.default {} - -(0, _core.setComponentTemplate)({ - "id": "UnWFMClF", - "block": "[[[10,\"h1\"],[12],[1,\"Hello world\"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}, Class1Declaration) -const Class1Expression = (0, _core.setComponentTemplate)({ - "id": "UnWFMClF", - "block": "[[[10,\"h1\"],[12],[1,\"Hello world\"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}, class extends _component.default {}); - -class Class2Declaration extends _component.default {} - -(0, _core.setComponentTemplate)({ - "id": "PN1+SdGD", - "block": "[[[10,\"h2\"],[12],[1,\"\\n Goodbye world\\n \"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}, Class2Declaration) -const Class2Expression = (0, _core.setComponentTemplate)({ - "id": "E/B0dLEA", - "block": "[[[10,\"h2\"],[12],[1,\"\\n Goodbye world\"],[8,[32,0],null,null,null],[1,\"\\n \"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [Class1Expression], - "isStrictMode": true -}, class extends _component.default {}); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-same-scope-var-commonjs/.babelrc b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-same-scope-var-commonjs/.babelrc deleted file mode 100644 index 65f8b13e..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-same-scope-var-commonjs/.babelrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "plugins": [ - "@babel/plugin-transform-modules-commonjs" - ] -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-same-scope-var-commonjs/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-same-scope-var-commonjs/code.js deleted file mode 100644 index 17f023be..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-same-scope-var-commonjs/code.js +++ /dev/null @@ -1,11 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; -import { OtherComponent as ExternalComponent } from 'somewhere'; - -class MyComponent extends Component { - static template = hbs`

Hello

` -} - -class OtherComponent extends Component { - static template = hbs`

Hello

` -} - diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-same-scope-var-commonjs/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-same-scope-var-commonjs/output.js deleted file mode 100644 index fd8401b6..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes-same-scope-var-commonjs/output.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; - -var _core = require("@glimmer/core"); - -var _component = _interopRequireDefault(require("@glimmerx/component")); - -var _somewhere = require("somewhere"); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -class MyComponent extends _component.default {} - -(0, _core.setComponentTemplate)({ - "id": "rUcvMrKh", - "block": "[[[10,\"h1\"],[12],[1,\"Hello \"],[8,[32,0],null,null,null],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [_somewhere.OtherComponent], - "isStrictMode": true -}, MyComponent) - -class OtherComponent extends _component.default {} - -(0, _core.setComponentTemplate)({ - "id": "rUcvMrKh", - "block": "[[[10,\"h1\"],[12],[1,\"Hello \"],[8,[32,0],null,null,null],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [_somewhere.OtherComponent], - "isStrictMode": true -}, OtherComponent) diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes/code.js deleted file mode 100644 index 684580c8..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes/code.js +++ /dev/null @@ -1,21 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; - -class Class1Declaration extends Component { - static template = hbs`

Hello world

`; -} - -const Class1Expression = class extends Component { - static template = hbs`

Hello world

`; -} - -class Class2Declaration extends Component { - static template = hbs`

- Goodbye world -

`; -} - -const Class2Expression = class extends Component { - static template = hbs`

- Goodbye world -

`; -} \ No newline at end of file diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes/output.js deleted file mode 100644 index a5111d33..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiple-classes/output.js +++ /dev/null @@ -1,38 +0,0 @@ -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import Component from '@glimmerx/component'; - -class Class1Declaration extends Component {} - -_setComponentTemplate({ - "id": "UnWFMClF", - "block": "[[[10,\"h1\"],[12],[1,\"Hello world\"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}, Class1Declaration) - -const Class1Expression = _setComponentTemplate({ - "id": "UnWFMClF", - "block": "[[[10,\"h1\"],[12],[1,\"Hello world\"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}, class extends Component {}); - -class Class2Declaration extends Component {} - -_setComponentTemplate({ - "id": "PN1+SdGD", - "block": "[[[10,\"h2\"],[12],[1,\"\\n Goodbye world\\n \"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}, Class2Declaration) - -const Class2Expression = _setComponentTemplate({ - "id": "E/B0dLEA", - "block": "[[[10,\"h2\"],[12],[1,\"\\n Goodbye world\"],[8,[32,0],null,null,null],[1,\"\\n \"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [Class1Expression], - "isStrictMode": true -}, class extends Component {}); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiscope-tokens/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiscope-tokens/code.js deleted file mode 100644 index 09761daf..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiscope-tokens/code.js +++ /dev/null @@ -1,16 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -import PhantomComponent from './PhantomComponent'; -import SecondPhantomComponent from './SecondPhantomComponent' - - -class MyComponent extends Component { - static template = hbs` -

Hello world - {{#OtherComponent as |SecondPhantomComponent|}} - - {{SecondPhantomComponent}} - {{/OtherComponent}} - -

`; -} \ No newline at end of file diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiscope-tokens/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiscope-tokens/output.js deleted file mode 100644 index eee21b42..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/multiscope-tokens/output.js +++ /dev/null @@ -1,15 +0,0 @@ -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import Component from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -import PhantomComponent from './PhantomComponent'; -import SecondPhantomComponent from './SecondPhantomComponent'; - -class MyComponent extends Component {} - -_setComponentTemplate({ - "id": "k3C9+Wms", - "block": "[[[1,\"\\n \"],[10,\"h1\"],[12],[1,\"Hello world \\n\"],[6,[32,0],null,null,[[\"default\"],[[[[1,\" \"],[8,[30,1],null,null,null],[1,\"\\n \"],[1,[30,1]],[1,\"\\n\"]],[1]]]]],[1,\" \"],[8,[32,1],null,null,null],[1,\"\\n \"],[13]],[\"SecondPhantomComponent\"],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [OtherComponent, SecondPhantomComponent], - "isStrictMode": true -}, MyComponent) diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/nested-classes/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/nested-classes/code.js deleted file mode 100644 index 9068a52d..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/nested-classes/code.js +++ /dev/null @@ -1,12 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; - -class MyComponent extends Component { - static template = hbs`

Hello world

`; - - get ChildComponent() { - return class extends Component { - static template = hbs`

Goodbye world

`; - } - } -} \ No newline at end of file diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/nested-classes/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/nested-classes/output.js deleted file mode 100644 index fa15e1c9..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/nested-classes/output.js +++ /dev/null @@ -1,24 +0,0 @@ -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import Component from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; - -class MyComponent extends Component { - get ChildComponent() { - return _setComponentTemplate({ - "id": "6fvPPcRc", - "block": "[[[10,\"h2\"],[12],[1,\"Goodbye world\"],[8,[32,0],null,null,null],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [MyComponent], - "isStrictMode": true - }, class extends Component {}); - } - -} - -_setComponentTemplate({ - "id": "7ZfYXn5W", - "block": "[[[10,\"h1\"],[12],[1,\"Hello world\"],[8,[32,0],null,null,null],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [OtherComponent], - "isStrictMode": true -}, MyComponent) diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/phantom-scope/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/phantom-scope/code.js deleted file mode 100644 index b6d35dd2..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/phantom-scope/code.js +++ /dev/null @@ -1,8 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -import PhantomComponent from './PhantomComponent'; - - -class MyComponent extends Component { - static template = hbs`

Hello world

`; -} \ No newline at end of file diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/phantom-scope/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/phantom-scope/output.js deleted file mode 100644 index 7504667f..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/phantom-scope/output.js +++ /dev/null @@ -1,14 +0,0 @@ -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import Component from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -import PhantomComponent from './PhantomComponent'; - -class MyComponent extends Component {} - -_setComponentTemplate({ - "id": "vVhfCDf6", - "block": "[[[10,\"h1\"],[12],[1,\"Hello world \"],[8,[32,0],null,null,null],[1,\" \"],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [OtherComponent], - "isStrictMode": true -}, MyComponent) diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/.babelrc b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/.babelrc deleted file mode 100644 index 65f8b13e..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/.babelrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "plugins": [ - "@babel/plugin-transform-modules-commonjs" - ] -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/code.js deleted file mode 100644 index 30d27490..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/code.js +++ /dev/null @@ -1,11 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -import YetAnotherComponent from './YetAnotherComponent'; - -class MyComponent extends Component { - static template = hbs`

Hello world

`; -} - -const MyComponentExpression = class extends Component { - static template = hbs``; -}; diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/options.json b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/options.json deleted file mode 100644 index 160eda7c..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "precompile": { - "disabled": true - } -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/output.js deleted file mode 100644 index 1701894f..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-commonjs/output.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; - -var _core = require("@glimmer/core"); - -var _component = _interopRequireDefault(require("@glimmerx/component")); - -var _OtherComponent = _interopRequireDefault(require("./OtherComponent")); - -var _YetAnotherComponent = _interopRequireDefault(require("./YetAnotherComponent")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -class MyComponent extends _component.default {} - -(0, _core.setComponentTemplate)((0, _core.createTemplate)({ - OtherComponent: _OtherComponent.default -}, `

Hello world

`), MyComponent) -const MyComponentExpression = (0, _core.setComponentTemplate)((0, _core.createTemplate)({ - YetAnotherComponent: _YetAnotherComponent.default -}, ``), class extends _component.default {}); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-hbs/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-hbs/code.js deleted file mode 100644 index 8f47ea07..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-hbs/code.js +++ /dev/null @@ -1,6 +0,0 @@ -import { hbs } from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -import YetAnotherComponent from './YetAnotherComponent'; - -const template1 = hbs`

Hello world

`; -const template2 = hbs``; \ No newline at end of file diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-hbs/options.json b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-hbs/options.json deleted file mode 100644 index 160eda7c..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-hbs/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "precompile": { - "disabled": true - } -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-hbs/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-hbs/output.js deleted file mode 100644 index 7003adc6..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled-hbs/output.js +++ /dev/null @@ -1,13 +0,0 @@ -import { createTemplate as _createTemplate } from "@glimmer/core"; -import { templateOnlyComponent as _templateOnlyComponent } from "@glimmer/core"; -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import OtherComponent from './OtherComponent'; -import YetAnotherComponent from './YetAnotherComponent'; - -const template1 = _setComponentTemplate(_createTemplate({ - OtherComponent: OtherComponent -}, `

Hello world

`), _templateOnlyComponent()); - -const template2 = _setComponentTemplate(_createTemplate({ - YetAnotherComponent: YetAnotherComponent -}, ``), _templateOnlyComponent()); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled/code.js deleted file mode 100644 index 30d27490..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled/code.js +++ /dev/null @@ -1,11 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -import YetAnotherComponent from './YetAnotherComponent'; - -class MyComponent extends Component { - static template = hbs`

Hello world

`; -} - -const MyComponentExpression = class extends Component { - static template = hbs``; -}; diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled/options.json b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled/options.json deleted file mode 100644 index 160eda7c..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled/options.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "precompile": { - "disabled": true - } -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled/output.js deleted file mode 100644 index 9b73cd74..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/precompile-disabled/output.js +++ /dev/null @@ -1,15 +0,0 @@ -import { createTemplate as _createTemplate } from "@glimmer/core"; -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import Component from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -import YetAnotherComponent from './YetAnotherComponent'; - -class MyComponent extends Component {} - -_setComponentTemplate(_createTemplate({ - OtherComponent: OtherComponent -}, `

Hello world

`), MyComponent) - -const MyComponentExpression = _setComponentTemplate(_createTemplate({ - YetAnotherComponent: YetAnotherComponent -}, ``), class extends Component {}); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/private-local-declarations/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/private-local-declarations/code.js deleted file mode 100644 index dcc662b2..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/private-local-declarations/code.js +++ /dev/null @@ -1,13 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; - -function root() { - function nested() { - class OtherComponent extends Component { - static template = hbs`Hello World`; - } - - class MyComponent extends Component { - static template = hbs`

` - } - } -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/private-local-declarations/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/private-local-declarations/output.js deleted file mode 100644 index 8fe5dec4..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/private-local-declarations/output.js +++ /dev/null @@ -1,26 +0,0 @@ -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import Component from '@glimmerx/component'; - -function root() { - function nested() { - class OtherComponent extends Component {} - - _setComponentTemplate({ - "id": "JlcONgyA", - "block": "[[[1,\"Hello World\"]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true - }, OtherComponent) - - class MyComponent extends Component {} - - _setComponentTemplate({ - "id": "L6QsX14w", - "block": "[[[10,\"h1\"],[12],[8,[32,0],null,null,null],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [OtherComponent], - "isStrictMode": true - }, MyComponent) - } -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens-hbs/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens-hbs/code.js deleted file mode 100644 index ad03d1fc..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens-hbs/code.js +++ /dev/null @@ -1,17 +0,0 @@ -import { hbs } from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -import PhantomComponent from './PhantomComponent'; -import SecondPhantomComponent from './SecondPhantomComponent' - - -const hbsOnlyTemplate = hbs` -

Hello world - {{#OtherComponent as |SecondPhantomComponent|}} - - {{SecondPhantomComponent}} - {{/OtherComponent}} - - - {{PhantomComponent}} - -

`; \ No newline at end of file diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens-hbs/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens-hbs/output.js deleted file mode 100644 index 149f340e..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens-hbs/output.js +++ /dev/null @@ -1,13 +0,0 @@ -import { templateOnlyComponent as _templateOnlyComponent } from "@glimmer/core"; -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import OtherComponent from './OtherComponent'; -import PhantomComponent from './PhantomComponent'; -import SecondPhantomComponent from './SecondPhantomComponent'; - -const hbsOnlyTemplate = _setComponentTemplate({ - "id": "yGo9zi+C", - "block": "[[[1,\"\\n\"],[10,\"h1\"],[12],[1,\"Hello world\\n\"],[6,[32,0],null,null,[[\"default\"],[[[[1,\" \"],[8,[30,1],null,null,null],[1,\"\\n \"],[1,[30,1]],[1,\"\\n\"]],[1]]]]],[1,\" \"],[8,[32,0],null,null,[[\"default\"],[[[[1,\"\\n \"],[8,[30,2],null,null,null],[1,\"\\n \"],[1,[30,2]],[1,\"\\n \"]],[2]]]]],[1,\"\\n\"],[13]],[\"SecondPhantomComponent\",\"PhantomComponent\"],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [OtherComponent], - "isStrictMode": true -}, _templateOnlyComponent()); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens/code.js deleted file mode 100644 index 87d6e616..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens/code.js +++ /dev/null @@ -1,19 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -import PhantomComponent from './PhantomComponent'; -import SecondPhantomComponent from './SecondPhantomComponent' - - -class MyComponent extends Component { - static template = hbs` -

Hello world - {{#OtherComponent as |SecondPhantomComponent|}} - - {{SecondPhantomComponent}} - {{/OtherComponent}} - - - {{PhantomComponent}} - -

`; -} \ No newline at end of file diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens/output.js deleted file mode 100644 index 57d3fc4d..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/scoped-tokens/output.js +++ /dev/null @@ -1,15 +0,0 @@ -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import Component from '@glimmerx/component'; -import OtherComponent from './OtherComponent'; -import PhantomComponent from './PhantomComponent'; -import SecondPhantomComponent from './SecondPhantomComponent'; - -class MyComponent extends Component {} - -_setComponentTemplate({ - "id": "msP/XLKt", - "block": "[[[1,\"\\n \"],[10,\"h1\"],[12],[1,\"Hello world \\n\"],[6,[32,0],null,null,[[\"default\"],[[[[1,\" \"],[8,[30,1],null,null,null],[1,\"\\n \"],[1,[30,1]],[1,\"\\n\"]],[1]]]]],[1,\" \"],[8,[32,0],null,null,[[\"default\"],[[[[1,\"\\n \"],[8,[30,2],null,null,null],[1,\" \\n \"],[1,[30,2]],[1,\"\\n \"]],[2]]]]],[1,\"\\n \"],[13]],[\"SecondPhantomComponent\",\"PhantomComponent\"],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [OtherComponent], - "isStrictMode": true -}, MyComponent) diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs-with-component-import/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs-with-component-import/code.js deleted file mode 100644 index d982d511..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs-with-component-import/code.js +++ /dev/null @@ -1,9 +0,0 @@ -import { renderComponent } from '@glimmer/core'; -import IamGlimmerComponent, { hbs } from '@glimmerx/component'; - -renderComponent(hbs`

Hello {{@name}}

`, { - args: { - name: 'Abhishek' - }, - element: document.body -}); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs-with-component-import/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs-with-component-import/output.js deleted file mode 100644 index 04370172..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs-with-component-import/output.js +++ /dev/null @@ -1,16 +0,0 @@ -import { templateOnlyComponent as _templateOnlyComponent } from "@glimmer/core"; -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import { renderComponent } from '@glimmer/core'; -import IamGlimmerComponent from '@glimmerx/component'; -renderComponent(_setComponentTemplate({ - "id": "n6RNQdbP", - "block": "[[[10,\"h1\"],[12],[1,\"Hello \"],[1,[30,1]],[13]],[\"@name\"],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}, _templateOnlyComponent()), { - args: { - name: 'Abhishek' - }, - element: document.body -}); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs/code.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs/code.js deleted file mode 100644 index b91003ec..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs/code.js +++ /dev/null @@ -1,9 +0,0 @@ -import { renderComponent } from '@glimmer/core'; -import { hbs } from '@glimmerx/component'; - -renderComponent(hbs`

Hello {{@name}}

`, { - args: { - name: 'Abhishek' - }, - element: document.body -}); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs/output.js b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs/output.js deleted file mode 100644 index d1779d5c..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/template-only-hbs/output.js +++ /dev/null @@ -1,15 +0,0 @@ -import { templateOnlyComponent as _templateOnlyComponent } from "@glimmer/core"; -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import { renderComponent } from '@glimmer/core'; -renderComponent(_setComponentTemplate({ - "id": "n6RNQdbP", - "block": "[[[10,\"h1\"],[12],[1,\"Hello \"],[1,[30,1]],[13]],[\"@name\"],false,[]]", - "moduleName": "(unknown template module)", - "scope": null, - "isStrictMode": true -}, _templateOnlyComponent()), { - args: { - name: 'Abhishek' - }, - element: document.body -}); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/typescript/.babelrc b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/typescript/.babelrc deleted file mode 100644 index 614696c6..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/typescript/.babelrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "presets": [ - "@babel/preset-typescript" - ] -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/typescript/code.ts b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/typescript/code.ts deleted file mode 100644 index da99e0ac..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/typescript/code.ts +++ /dev/null @@ -1,13 +0,0 @@ -import Component, { hbs } from '@glimmerx/component'; -import { Dict } from '@glimmer/interfaces'; -import MaybeComponent from './somewhere-else'; -const unknownValue = null; -const maybeModifier = null; - -export function foo(): Dict { - return {}; -} - -export class MyComponent extends Component { - static template = hbs`

Hello world {{unknownValue}}

`; -} diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/typescript/output.ts b/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/typescript/output.ts deleted file mode 100644 index a15487e6..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/fixtures/typescript/output.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { setComponentTemplate as _setComponentTemplate } from "@glimmer/core"; -import Component from '@glimmerx/component'; -import MaybeComponent from './somewhere-else'; -const unknownValue = null; -const maybeModifier = null; -export function foo() { - return {}; -} -export class MyComponent extends Component {} - -_setComponentTemplate({ - "id": "jFBJ3iUu", - "block": "[[[11,\"h1\"],[4,[32,0],null,null],[12],[1,\"Hello world \"],[1,[32,1]],[8,[32,2],null,null,null],[13]],[],false,[]]", - "moduleName": "(unknown template module)", - "scope": () => [maybeModifier, unknownValue, MaybeComponent], - "isStrictMode": true -}, MyComponent); diff --git a/packages/@glimmerx/babel-plugin-component-templates/test/index.js b/packages/@glimmerx/babel-plugin-component-templates/test/index.js deleted file mode 100644 index ec1682db..00000000 --- a/packages/@glimmerx/babel-plugin-component-templates/test/index.js +++ /dev/null @@ -1,88 +0,0 @@ -import plugin from '..'; -import pluginTester from 'babel-plugin-tester'; -import path from 'path'; -import astTransformTestPluginOptions from './fixtures-options/precompile/ast-transform/options'; -import customPrecompileTestPluginOptions from './fixtures-options/precompile/custom/options'; -const { addNamed } = require('@babel/helper-module-imports'); - - -// For correct .babelrc detection inside the fixture directory we need to force babel's cwd and root to be the package root. -// This will ensure that the tests will run correctly from the mono repo root or package root. -const packageRootPath = path.resolve(__dirname, '..'); - -pluginTester({ - plugin, - babelOptions: { - cwd: packageRootPath, - root: packageRootPath - }, - fixtures: path.join(__dirname, 'fixtures'), - tests: [ - { - title: 'options.precompile : ast transfrom', - fixture: path.join(__dirname, 'fixtures-options/precompile/ast-transform/code.js'), - outputFixture: path.join(__dirname, 'fixtures-options/precompile/ast-transform/output.js'), - pluginOptions: astTransformTestPluginOptions, - }, - { - title: 'options.precompile : ast transfrom hbs only', - fixture: path.join(__dirname, 'fixtures-options/precompile/ast-transform-hbs/code.js'), - outputFixture: path.join(__dirname, 'fixtures-options/precompile/ast-transform-hbs/output.js'), - pluginOptions: astTransformTestPluginOptions, - }, - { - title: 'options.precompile : custom precompile', - fixture: path.join(__dirname, 'fixtures-options/precompile/custom/code.js'), - outputFixture: path.join(__dirname, 'fixtures-options/precompile/custom/output.js'), - pluginOptions: customPrecompileTestPluginOptions, - }, - ], -}); - -pluginTester({ - plugin: () => { return { name: 'ordering-of-plugins', visitor: {} }}, - babelOptions: { - cwd: packageRootPath, - root: packageRootPath, - plugins: [ - [addImport], - [plugin], - ['@babel/plugin-proposal-class-properties', { loose: true }] - ] - }, - fixtures: path.join(__dirname, 'fixtures-compat') -}) - -pluginTester({ - plugin: () => { return { name: 'ordering-of-plugins-precompile-options', visitor: {} }}, - babelOptions: { - cwd: packageRootPath, - root: packageRootPath, - plugins: [ - [addImport], - [plugin, { - "precompile": { - "disabled": true - } - }], - ['@babel/plugin-proposal-class-properties', { loose: true }] - ] - }, - fixtures: path.join(__dirname, 'fixtures-compat-options') -}) - - -function addImport() { - return { - name: 'introduce-import', - visitor: { - Program(path) { - addNamed(path, 't', 't-helper'); - path.get('body').forEach(declaration => { - declaration.isImportDeclaration() && - path.scope.registerDeclaration(declaration); - }); - } - } - } -} diff --git a/packages/@glimmerx/babel-preset/index.js b/packages/@glimmerx/babel-preset/index.js new file mode 100644 index 00000000..ed02f52d --- /dev/null +++ b/packages/@glimmerx/babel-preset/index.js @@ -0,0 +1,30 @@ +function defaultTo(value, defaultVal) { + return value === undefined ? defaultVal : value; +} + +module.exports = function (api, options) { + let __loadPlugins = defaultTo(options.__loadPlugins, false); + + return { + presets: [ + [ + __loadPlugins ? require('@glimmer/babel-preset') : require.resolve('@glimmer/babel-preset'), + { + ...options, + __customInlineTemplateModules: { + '@glimmerx/component': { + export: 'hbs', + useTemplateLiteralProposalSemantics: 1, + }, + + 'TEMPLATE-TAG-MODULE': { + export: 'GLIMMER_TEMPLATE', + debugName: '