Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add v2 addon metadata #20744

Merged
merged 1 commit into from
Sep 12, 2024
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
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"keywords": [
"ember-addon"
],
"exports": {
"./*": "./dist/packages/*",
"./dist/ember-template-compiler.js": "./dist/ember-template-compiler.js",
"./package.json": "./package.json"
},
"homepage": "https://emberjs.com/",
"bugs": {
"url": "https://github.com/emberjs/ember.js/issues"
Expand Down Expand Up @@ -174,7 +179,8 @@
"node": ">= 18.*"
},
"ember-addon": {
"after": "ember-cli-legacy-blueprints"
"after": "ember-cli-legacy-blueprints",
"type": "addon"
},
"typesVersions": {
"*": {
Expand Down
27 changes: 26 additions & 1 deletion rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { dirname, parse, resolve, join } from 'node:path';
import { existsSync, readFileSync, statSync } from 'node:fs';
import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';
import { createRequire } from 'node:module';
import { fileURLToPath } from 'node:url';
import glob from 'glob';
Expand Down Expand Up @@ -71,6 +71,7 @@ function esmConfig() {
version(),
resolvePackages({ ...exposedDependencies(), ...hiddenDependencies() }),
pruneEmptyBundles(),
packageMeta(),
],
};
}
Expand Down Expand Up @@ -498,6 +499,30 @@ function pruneEmptyBundles() {
};
}

function packageMeta() {
let renamedModules = Object.fromEntries(
glob
.sync('**/*.js', { cwd: 'dist/packages', ignore: ['shared-chunks/**'], nodir: true })
.map((name) => {
return [name, 'ember-source/' + name];
})
);
return {
name: 'package-meta',
buildEnd(error) {
if (error) {
return;
}
let pkg = JSON.parse(readFileSync('package.json'));
if (!pkg['ember-addon']) {
pkg['ember-adodn'] = {};
}
pkg['ember-addon']['renamed-modules'] = renamedModules;
writeFileSync('package.json', JSON.stringify(pkg, null, 2));
},
};
}

function handleRollupWarnings(level, log, handler) {
switch (log.code) {
case 'CIRCULAR_DEPENDENCY':
Expand Down