Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions files/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -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,
},
};
24 changes: 0 additions & 24 deletions files/babel.config.json

This file was deleted.

31 changes: 31 additions & 0 deletions files/babel.publish.config.cjs
Original file line number Diff line number Diff line change
@@ -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,
},
};
23 changes: 15 additions & 8 deletions files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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"<% } %>
},
Expand Down
5 changes: 5 additions & 0 deletions files/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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.
Expand Down
28 changes: 28 additions & 0 deletions files/tests/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title><%= name %> Tests</title>
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">
<div id="ember-testing-container">
<div id="ember-testing"></div>
</div>
</div>

<script src="/testem.js" integrity="" data-embroider-ignore></script>
<script type="module">
import "ember-testing";
</script>

<script type="module">
import { start } from "./test-helper.js";
import.meta.glob("./**/*.{js,ts,gjs,gts}", { eager: true });
start();
</script>
</body>
</html>
35 changes: 35 additions & 0 deletions files/tests/test-helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import EmberApp from '@ember/application';
import Resolver from 'ember-resolver';
import EmberRouter from '@ember/routing/router';

class Router extends EmberRouter {
location = 'none';
rootURL = '/';
}

class TestApp extends EmberApp {
modulePrefix = 'test-app';
Resolver = Resolver.withModules({
'test-app/router': { default: Router },
// add any custom services here
});
}

Router.map(function () {});

import * as QUnit from 'qunit';
import { setApplication } from '@ember/test-helpers';
import { setup } from 'qunit-dom';
import { start as qunitStart, setupEmberOnerrorValidation } from 'ember-qunit';

export function start() {
setApplication(
TestApp.create({
autoboot: false,
rootElement: '#ember-testing',
}),
);
setup(QUnit.assert);
setupEmberOnerrorValidation();
qunitStart();
}
20 changes: 20 additions & 0 deletions files/vite.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { defineConfig } from 'vite';
import { extensions, ember, classicEmberSupport } from '@embroider/vite';
import { babel } from '@rollup/plugin-babel';

export default defineConfig({
plugins: [
ember(),
babel({
babelHelpers: 'inline',
extensions,
}),
],
build: {
rollupOptions: {
input: {
tests: 'tests/index.html',
},
},
},
});