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

Rollup/Build tweaks #1601

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"build": "dotenv -- turbo build",
"build:control": "rollup -c rollup.config.mjs",
"build:flags": "RETAIN_FLAGS=true ember build --env production --suppress-sizes",
"link:all": "esyes ./bin/link-all.mts",
"clean": "node ./bin/clean.mjs",
"link:all": "esyes ./bin/link-all.mts",
"lint": "npm-run-all lint:*",
"lint:files": "turbo lint",
"lint:format": "prettier -c .",
Expand Down Expand Up @@ -171,5 +171,6 @@
"volta": {
"node": "20.9.0",
"pnpm": "8.5.0"
}
},
"packageManager": "[email protected]"
}
72 changes: 31 additions & 41 deletions packages/@glimmer-workspace/build/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import { existsSync, readFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import terser from '@rollup/plugin-terser';
import * as insert from 'rollup-plugin-insert';
import rollupTS from 'rollup-plugin-ts';
import ts from 'typescript';

import importMeta from './import-meta.js';
Expand All @@ -18,10 +19,7 @@ import inline from './inline.js';
const { ModuleKind, ModuleResolutionKind, ScriptTarget, ImportsNotUsedAsValues } = ts;

const { default: commonjs } = await import('@rollup/plugin-commonjs');
const { default: nodeResolve } = await import('@rollup/plugin-node-resolve');
const { default: postcss } = await import('rollup-plugin-postcss');
const { default: nodePolyfills } = await import('rollup-plugin-polyfill-node');
const { default: fonts } = await import('unplugin-fonts/vite');

/** @typedef {import("typescript").CompilerOptions} CompilerOptions */
/** @typedef {import("./config.js").ExternalOption} ExternalOption */
Expand Down Expand Up @@ -77,32 +75,13 @@ export function tsconfig(updates) {
* @returns {RollupPlugin}
*/
export function typescript(pkg, config) {
const typeScriptConfig = {
...config,
paths: {
'@glimmer/interfaces': [resolve(pkg.root, '../@glimmer/interfaces/index.d.ts')],
'@glimmer/*': [resolve(pkg.root, '../@glimmer/*/src/dist/index.d.ts')],
},
};

/** @type {[string, object][]} */
const presets = [['@babel/preset-typescript', { allowDeclareFields: true }]];

const ts = tsconfig(typeScriptConfig);

/**
* TODO: migrate off of rollupTS, it has too many bugs
*/
return rollupTS({
transpiler: 'babel',
transpileOnly: true,
babelConfig: { presets },
/**
* This shouldn't be required, but it is.
* If we use @rollup/plugin-babel, we can remove this.
*/
browserslist: [`last 1 chrome versions`],
tsconfig: ts,
return babel({
extensions: ['.js', '.ts'],
babelHelpers: 'inline',
presets,
});
}

Expand Down Expand Up @@ -278,15 +257,6 @@ export class Package {
*/
async #viteConfig() {
return viteConfig({
plugins: [
fonts({
google: {
families: ['Roboto:wght@300;400;500;700'],
display: 'swap',
preconnect: true,
},
}),
],
optimizeDeps: {
esbuildOptions: {
define: {
Expand All @@ -313,10 +283,30 @@ export class Package {
inline(),
nodePolyfills(),
commonjs(),
nodeResolve(),
nodeResolve({ extensions: ['.js', '.ts'] }),
...this.replacements(env),
...(env === 'prod' ? [terser()] : []),
postcss(),
...(env === 'prod'
? [
terser({
module: true,
compress: {
passes: 3,
},
}),
]
: [
terser({
module: true,
mangle: false,
compress: {
passes: 3,
},
format: {
comments: 'all',
beautify: true,
},
}),
]),
typescript(this.#package, {
target: ScriptTarget.ES2022,
importsNotUsedAsValues: ImportsNotUsedAsValues.Preserve,
Expand All @@ -337,9 +327,8 @@ export class Package {
inline(),
nodePolyfills(),
commonjs(),
nodeResolve(),
nodeResolve({ extensions: ['.js', '.ts'] }),
...this.replacements(env),
postcss(),
typescript(this.#package, {
target: ScriptTarget.ES2021,
module: ModuleKind.CommonJS,
Expand Down Expand Up @@ -422,6 +411,7 @@ export class Package {
format,
sourcemap: true,
exports: format === 'cjs' ? 'named' : 'auto',
hoistTransitiveImports: false,
},
onwarn: (warning, warn) => {
switch (warning.code) {
Expand Down
1 change: 1 addition & 0 deletions packages/@glimmer-workspace/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"test:types": "tsc --noEmit -p ../tsconfig.json"
},
"dependencies": {
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.5",
Expand Down
5 changes: 0 additions & 5 deletions packages/@glimmer/runtime/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* @deprecated use RichIteratorResult<Tick, Return> or TemplateIterator instead
*/
import './lib/bootstrap';

import type { RichIteratorResult } from '@glimmer/interfaces';

export { clear, ConcreteBounds, CursorImpl } from './lib/bounds';
Expand Down
8 changes: 0 additions & 8 deletions packages/@glimmer/runtime/lib/bootstrap.ts

This file was deleted.

Loading
Loading