diff --git a/files/babel.config.cjs b/files/babel.config.cjs new file mode 100644 index 0000000..3711409 --- /dev/null +++ b/files/babel.config.cjs @@ -0,0 +1,32 @@ +const { buildMacros } = require('@embroider/macros/babel'); + +const macros = buildMacros(); + +module.exports = { + plugins: [<% if (typescript) { %> + ['@babel/plugin-transform-typescript', { + allowDeclareFields: true, + onlyRemoveTypeImports: true, + allowDeclareFields: true, + }],<% } %> + [ + 'babel-plugin-ember-template-compilation', + { + transforms: [...macros.templateMacros], + }, + ], + [ + 'module:decorator-transforms', + { + runtime: { + import: require.resolve('decorator-transforms/runtime-esm'), + }, + }, + ], + ...macros.babelMacros, + ], + + generatorOpts: { + compact: false, + }, +}; diff --git a/files/babel.config.json b/files/babel.config.json deleted file mode 100644 index 3f58702..0000000 --- a/files/babel.config.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "plugins": [ -<% if (typescript) { %> [ - "@babel/plugin-transform-typescript", - { - "allExtensions": true, - "onlyRemoveTypeImports": true, - "allowDeclareFields": true - } - ], -<% } %> "@embroider/addon-dev/template-colocation-plugin", - [ - "babel-plugin-ember-template-compilation", - { - "targetFormat": "hbs", - "transforms": [] - } - ], - [ - "module:decorator-transforms", - { "runtime": { "import": "decorator-transforms/runtime" } } - ] - ] -} diff --git a/files/babel.publish.config.cjs b/files/babel.publish.config.cjs new file mode 100644 index 0000000..f00a6db --- /dev/null +++ b/files/babel.publish.config.cjs @@ -0,0 +1,31 @@ +module.exports = { + plugins: [<% if (typescript) { %> + [ + '@babel/plugin-transform-typescript', + { + allExtensions: true, + onlyRemoveTypeImports: true, + allowDeclareFields: true, + }, + ],<% } %> + [ + 'babel-plugin-ember-template-compilation', + { + targetFormat: 'hbs', + transforms: [] + }, + ], + [ + 'module:decorator-transforms', + { + runtime: { + import: 'decorator-transforms/runtime-esm', + }, + }, + ], + ], + + generatorOpts: { + compact: false, + }, +}; diff --git a/files/package.json b/files/package.json index d83fd15..0207d2d 100644 --- a/files/package.json +++ b/files/package.json @@ -24,8 +24,8 @@ "lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern", "lint:js:fix": "eslint . --fix",<% if (typescript) { %> "lint:types": "glint",<% } %> - "start": "rollup --config --watch", - "test": "echo 'A v2 addon does not have tests, run tests in test-app'", + "start": "vite dev", + "test": "vite build --mode=development && testem --file testem.js ci", "prepack": "rollup --config" }, "dependencies": { @@ -36,12 +36,15 @@ "ember-source": ">= 4.12.0" }, "devDependencies": { - "@babel/core": "^7.25.2", - <% if (typescript) { %>"@babel/plugin-transform-typescript": "^7.25.2",<% } %> + "@babel/core": "^7.25.2",<% if (typescript) { %>"@babel/plugin-transform-typescript": "^7.25.2",<% } %> "@babel/eslint-parser": "^7.25.1", "@babel/runtime": "^7.25.6", - "@eslint/js": "^9.17.0", - "@embroider/addon-dev": "^7.1.0",<% if (typescript) { %> + "@embroider/addon-dev": "^7.1.0", + "@embroider/core": "^4.0.0-alpha.10", + "@embroider/macros": "^1.17.0-alpha.8", + "@embroider/vite": "^1.0.0-alpha.12", + "@ember/test-helpers": "^5.2.1", + "@eslint/js": "^9.17.0",<% if (typescript) { %> "@glint/core": "^1.4.0", "@glint/environment-ember-loose": "^1.4.0", "@glint/environment-ember-template-imports": "^1.4.0", @@ -50,8 +53,10 @@ "@rollup/plugin-babel": "^6.0.4", "babel-plugin-ember-template-compilation": "^2.2.5", "concurrently": "^9.0.1", - "ember-source": "^5.4.0", + "ember-source": "^6.3.0", + "ember-resolver": "^13.1.0", "ember-template-lint": "^6.0.0", + "ember-qunit": "^9.0.2", "eslint": "^9.17.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-ember": "^12.3.3", @@ -61,7 +66,9 @@ "prettier": "^3.4.2", "prettier-plugin-ember-template-tag": "^2.0.4", "rollup": "^4.22.5", - "rollup-plugin-copy": "^3.5.0"<% if (typescript) { %>, + "qunit": "^2.24.1", + "qunit-dom": "^3.4.0", + "vite": "^6.2.4"<% if (typescript) { %>, "typescript-eslint": "^8.19.1", "typescript": "~5.6.0"<% } %> }, diff --git a/files/rollup.config.mjs b/files/rollup.config.mjs index 254c2fb..d94a8a8 100644 --- a/files/rollup.config.mjs +++ b/files/rollup.config.mjs @@ -1,5 +1,6 @@ import { babel } from '@rollup/plugin-babel'; import { Addon } from '@embroider/addon-dev/rollup'; +import { fileURLToPath } from 'node:url'; const addon = new Addon({ srcDir: 'src', @@ -45,6 +46,10 @@ export default { babel({ extensions: ['.js', '.gjs'<% if (typescript) { %>, '.ts', '.gts'<% } %>], babelHelpers: 'bundled', + configFile: resolve( + dirname(fileURLToPath(import.meta.url)), + './babel.publish.config.cjs', + ), }), // Ensure that standalone .hbs files are properly integrated as Javascript. diff --git a/files/tests/index.html b/files/tests/index.html new file mode 100644 index 0000000..0dc0486 --- /dev/null +++ b/files/tests/index.html @@ -0,0 +1,28 @@ + + +
+ +