Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ assets/bpm_libs.js
assets/bpm_styles.css
coverage
dist
dist-prod
/docs
lib/*/tests/all.js
lib/*/tests/qunit*
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
"ember-addon"
],
"exports": {
"./*": "./dist/packages/*",
"./*": {
"development": "./dist/packages/*",
"production": "./dist-prod/packages/*",
"default": "./dist/packages/*"
},
"./types": {
"types": "./types/stable/index.d.ts"
},
Expand All @@ -24,6 +28,7 @@
"blueprints",
"dist/packages",
"dist/dependencies",
"dist-prod/packages",
"dist/ember-template-compiler.js",
"dist/ember-template-compiler.js.map",
"dist/ember.debug.js",
Expand Down Expand Up @@ -390,4 +395,4 @@
}
},
"packageManager": "pnpm@10.5.0"
}
}
93 changes: 52 additions & 41 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const testDependencies = [

let configs = [
esmConfig(),
esmTemplateCompiler(),
esmProdConfig(),
legacyBundleConfig('./broccoli/amd-compat-entrypoints/ember.debug.js', 'ember.debug.js', {
isDeveloping: true,
}),
Expand Down Expand Up @@ -55,64 +55,71 @@ export default configs;

function esmConfig() {
return sharedESMConfig({
input: {
...renameEntrypoints(exposedDependencies(), (name) => join('packages', name, 'index')),
...renameEntrypoints(packages(), (name) => join('packages', name)),
},
debugMacrosMode: '@embroider/macros',
input: esmInputs(),
debugMacrosMode: true,
includePackageMeta: true,
});
}

function esmTemplateCompiler() {
function esmProdConfig() {
return sharedESMConfig({
input: {
// the actual authored "./packages/ember-template-compiler/index.ts" is
// part of what powers the historical dist/ember-template-compiler.js AMD
// bundle. It has historical cruft that has never been present in our ESM
// builds.
//
// On the ESM build, the main entrypoint of ember-template-compiler is the
// "minimal.ts" version, which has a lot less in it.

'packages/ember-template-compiler/index': 'ember-template-compiler/minimal.ts',
},
// the template compiler is always in debug mode (and doesn't use
// embroider/macros, so it's directly invokable on node)
debugMacrosMode: true,
input: esmInputs(),
debugMacrosMode: false,
});
}

function sharedESMConfig({ input, debugMacrosMode }) {
function esmInputs() {
return {
...renameEntrypoints(exposedDependencies(), (name) => join('packages', name, 'index')),
...renameEntrypoints(packages(), (name) => join('packages', name)),
// the actual authored "./packages/ember-template-compiler/index.ts" is
// part of what powers the historical dist/ember-template-compiler.js AMD
// bundle. It has historical cruft that has never been present in our ESM
// builds.
//
// On the ESM build, the main entrypoint of ember-template-compiler is the
// "minimal.ts" version, which has a lot less in it.
'packages/ember-template-compiler/index': 'ember-template-compiler/minimal.ts',
};
}

function sharedESMConfig({ input, debugMacrosMode, includePackageMeta = false }) {
let outputDir = debugMacrosMode === false ? 'dist-prod' : 'dist';
let babelConfig = { ...sharedBabelConfig };
babelConfig.plugins = [
...babelConfig.plugins,
buildDebugMacroPlugin(debugMacrosMode),
canaryFeatures(),
];

let plugins = [
babel({
babelHelpers: 'bundled',
extensions: ['.js', '.ts'],
configFile: false,
...babelConfig,
}),
resolveTS(),
version(),
resolvePackages({ ...exposedDependencies(), ...hiddenDependencies() }),
pruneEmptyBundles(),
];

if (includePackageMeta) {
plugins.push(packageMeta());
}

return {
onLog: handleRollupWarnings,
input,
output: {
format: 'es',
dir: 'dist',
dir: outputDir,
hoistTransitiveImports: false,
generatedCode: 'es2015',
chunkFileNames: 'packages/shared-chunks/[name]-[hash].js',
},
plugins: [
babel({
babelHelpers: 'bundled',
extensions: ['.js', '.ts'],
configFile: false,
...babelConfig,
}),
resolveTS(),
version(),
resolvePackages({ ...exposedDependencies(), ...hiddenDependencies() }),
pruneEmptyBundles(),
packageMeta(),
],
plugins,
};
}

Expand Down Expand Up @@ -148,7 +155,7 @@ function renameEntrypoints(entrypoints, fn) {
function legacyBundleConfig(input, output, { isDeveloping, isExternal }) {
let babelConfig = { ...sharedBabelConfig };

babelConfig.plugins = [...babelConfig.plugins, buildDebugMacroPlugin(isDeveloping)];
babelConfig.plugins = [...babelConfig.plugins];

return {
input,
Expand Down Expand Up @@ -644,11 +651,15 @@ function pruneEmptyBundles() {
function packageMeta() {
return {
name: 'package-meta',
generateBundle() {
generateBundle(_outputOptions, bundle) {
let renamedModules = Object.fromEntries(
glob
.sync('packages/**/*.js', { cwd: 'dist', nodir: true })
.filter((name) => !name.startsWith('packages/shared-chunks/'))
Object.keys(bundle)
.filter(
(name) =>
name.startsWith('packages/') &&
!name.startsWith('packages/shared-chunks/') &&
name.endsWith('.js')
)
.sort()
.map((name) => {
return [
Expand Down
Loading