Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.
Draft
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default [
{
files: [
'files/*/app/**/*.js',
'files-override/*/*.js',
'files-override/*/app/**/*.js',
'files-override/*/tests/**/*.js',
],
Expand Down
13 changes: 2 additions & 11 deletions files-override/js/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,7 @@ export default [
* CJS node files
*/
{
files: [
'**/*.cjs',
'config/**/*.js',
'testem.js',
'testem*.js',
'.prettierrc.js',
'.stylelintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
],
files: ['**/*.cjs', 'config/**/*.js', 'testem.js', 'testem*.js'],
plugins: {
n,
},
Expand All @@ -96,7 +87,7 @@ export default [
* ESM node files
*/
{
files: ['*.mjs'],
files: ['*.mjs', '*.js'],
plugins: {
n,
},
Expand Down
2 changes: 1 addition & 1 deletion files-override/js/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</div>
</div>

<script src="/testem.js" integrity="" data-embroider-ignore></script>
<script src="/testem.cjs" integrity="" data-embroider-ignore></script>
<script src="/@embroider/core/vendor.js"></script>
<script src="/@embroider/core/test-support.js"></script>
<script type="module">import "ember-testing";</script>
Expand Down
3 changes: 3 additions & 0 deletions files-override/shared/.template-lintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
extends: 'recommended',
};
43 changes: 41 additions & 2 deletions files/js/app/config/environment.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
import loadConfigFromMeta from '@embroider/config-meta-loader';
// import loadConfigFromMeta from '@embroider/config-meta-loader';
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either this, or ember-cli, need to be made aware of the possibility of .cjs extensions for config/environment

//
// export default loadConfigFromMeta('<%= name %>');

export default loadConfigFromMeta('<%= name %>');
import { isTesting, isDevelopingApp } from '@embroider/macros';

const isTest = () => isTesting() || location.href.includes('/test');

export default {
modulePrefix: '<%= name %>',
environment: isTest()
? 'test'
: isDevelopingApp()
? 'development'
: 'production', // maybe,
rootURL: '/',
locationType: 'history',
EmberENV: {
EXTEND_PROTOTYPES: false,
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true
},
},

...(isTest()
? {
locationType: 'none',
}
: {}),

APP: {
...(isTest()
? {
LOG_ACTIVE_GENERATION: false,
LOG_VIEW_LOOKUPS: false,
rootElement: '#ember-testing',
autoboot: false,
}
: {}),
},
};
31 changes: 29 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const fs = require('fs');
const { join } = require('path');
const emberCliUpdate = require('./lib/ember-cli-update');
const copyWithTemplate = require('./lib/copy-with-template');
const { rm, readFile } = require('fs/promises');
const { cp, rm, readFile } = require('fs/promises');

const appBlueprint = Blueprint.lookup('app');

Expand Down Expand Up @@ -53,6 +53,8 @@ module.exports = {
'save-dev': true,
verbose: false,
packages: [
// Too many warnings
'ember-data',
// Not needed anymore
'ember-fetch',
'broccoli-asset-rev',
Expand Down Expand Up @@ -104,12 +106,29 @@ module.exports = {
'.eslintignore',
// replaced with .prettierrc.cjs
'.prettierrc.js',
// CJS (needs renamed)
'testem.js',
'ember-cli-build.js',
];

for (let file of filesToDelete) {
await rm(join(options.target, file));
}

const filesToSetAsCJS = [
'config/environment.js',
'config/targets.js',
'.stylelintrc.js',
];

for (let file of filesToSetAsCJS) {
await cp(
join(options.target, file),
join(options.target, file.replace(/\.js$/, '.cjs')),
);
await rm(join(options.target, file));
}

// there doesn't seem to be a way to tell ember-cli to not prompt to override files that were added in the beforeInstall
// so I'm just copying a few over at this stage
copyWithTemplate(
Expand All @@ -118,21 +137,29 @@ module.exports = {
options,
);

copyWithTemplate(
join(__dirname, 'files-override/shared'),
options.target,
options,
);

let packageJson = join(options.target, 'package.json');
let json = JSON.parse(fs.readFileSync(packageJson));

json.scripts = {
...json.scripts,
build: 'vite build',
start: 'vite',
'test:ember': 'vite build --mode test && ember test --path dist',
'test:ember':
'vite build --mode test && ember test --path dist --config-file ./testem.cjs',
};

json['ember-addon'] = {
type: 'app',
version: 2,
};

json.type = 'module';
json.exports = {
'./tests/*': './tests/*',
'./*': './app/*',
Expand Down
10 changes: 5 additions & 5 deletions tests/default.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ describe('basic functionality', function () {
let result;

try {
result = await execa('pnpm', ['test:ember'], {
result = await execa('pnpm', ['test:ember', '--test-port', '0'], {
cwd: join(tmpDir.path, appName),
});
} catch (err) {
console.log(err.stdout, err.stderr);
throw err;
throw 'Failed to successfully run test:ember';
}

// make sure that each of the tests that we expect actually show up
Expand Down Expand Up @@ -125,7 +125,7 @@ describe('basic functionality', function () {
});

writeFileSync(
join(tmpDir.path, appName, 'testem-dev.js'),
join(tmpDir.path, appName, 'testem-dev.cjs'),
`module.exports = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
Expand All @@ -147,15 +147,15 @@ describe('basic functionality', function () {
},
},
middleware: [
require(__dirname + '/testem-proxy.js')('${appURL}')
require(__dirname + '/testem-proxy.cjs')('${appURL}')
],
};
`,
);

let testResult = await execa(
'pnpm',
['testem', '--file', 'testem-dev.js', 'ci'],
['testem', '--file', 'testem-dev.cjs', 'ci'],
{
cwd: join(tmpDir.path, appName),
},
Expand Down