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

breaking: Update build targets. #237

Merged
merged 5 commits into from
Feb 21, 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
2 changes: 1 addition & 1 deletion packages/babel-plugin-cjs-esm-interop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"src/**/*"
],
"engines": {
"node": ">=16.12.0"
"node": ">=18.12.0"
},
"packemon": {
"format": "lib",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-conditional-invariant/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"src/**/*"
],
"engines": {
"node": ">=16.12.0"
"node": ">=18.12.0"
},
"packemon": {
"format": "lib",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-env-constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"src/**/*"
],
"engines": {
"node": ">=16.12.0"
"node": ">=18.12.0"
},
"packemon": {
"format": "lib",
Expand Down
2 changes: 1 addition & 1 deletion packages/packemon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
}
},
"engines": {
"node": ">=16.12.0"
"node": ">=18.12.0"
},
"packemon": {
"api": "private",
Expand Down
42 changes: 21 additions & 21 deletions packages/packemon/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,25 @@ export const EXCLUDE_RUST = [
// https://reactnative.dev/docs/javascript-environment
// Based on browserslist: https://github.com/browserslist/browserslist
export const NATIVE_TARGETS: { [K in Support]: string } = {
legacy: 'iOS 13', // 2019
stable: 'iOS 14', // 2020
current: 'iOS 15', // 2021
experimental: 'iOS 16', // 2022
legacy: 'iOS 14', // 2020
stable: 'iOS 15', // 2021
current: 'iOS 16', // 2022
experimental: 'iOS 17', // 2023
};

// Based on LTS schedule: https://nodejs.org/en/about/releases/
export const NODE_SUPPORTED_VERSIONS: { [K in Support]: string } = {
legacy: '14.15.0', // LTS support started
stable: '16.12.0', // ESM loader hooks
current: '18.12.0', // LTS support started
experimental: '19.0.0',
legacy: '16.12.0', // ESM loader hooks
stable: '18.12.0', // LTS support started
current: '20.10.0', // Detect module / CJS compat
experimental: '21.6.0',
};

export const NPM_SUPPORTED_VERSIONS: { [K in Support]: string } = {
legacy: '6.14.0',
stable: '8.1.0',
current: '8.19.0',
experimental: '9.0.0',
legacy: '8.1.0',
stable: '8.19.0',
current: '10.0.0',
experimental: '10.4.0',
};

// Based on browserslist: https://github.com/browserslist/browserslist
Expand All @@ -100,16 +100,16 @@ export const BROWSER_TARGETS: { [K in Support]: string[] | string } = {
};

export const ELECTRON_TARGETS: { [K in Support]: string } = {
legacy: '7.0.0', // Oct 2019
stable: '11.0.0', // Nov 2020
current: '16.0.0', // Nov 2021
experimental: '21.0.0', // Sep 2022
legacy: '11.0.0', // Nov 2020
stable: '16.0.0', // Nov 2021
current: '21.0.0', // Sep 2022
experimental: '26.0.0', // June 2023
};

export const SUPPORT_TO_ESM_SPEC = {
legacy: 'es2018',
stable: 'es2019',
current: 'es2020',
legacy: 'es2019',
stable: 'es2020',
current: 'es2021',
experimental: 'es2022',
} as const;

Expand All @@ -122,15 +122,15 @@ export const STATE_COLORS: { [K in ArtifactState]?: StyleType } = {
export const DEFAULT_FORMATS: Record<Platform, Format> = {
browser: 'esm',
electron: 'esm',
native: 'lib',
native: 'esm',
node: 'mjs',
};

export const FORMATS_BROWSER: BrowserFormat[] = ['lib', 'esm', 'umd'];

export const FORMATS_ELECTRON: BrowserFormat[] = ['lib', 'esm'];

export const FORMATS_NATIVE: NativeFormat[] = ['lib'];
export const FORMATS_NATIVE: NativeFormat[] = ['lib', 'esm'];

export const FORMATS_NODE: NodeFormat[] = ['lib', 'mjs', 'cjs'];

Expand Down
2 changes: 1 addition & 1 deletion packages/packemon/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type ElectronFormat =
// ECMAScript modules with ".js" file extension
| 'esm';

export type NativeFormat = CommonFormat;
export type NativeFormat = CommonFormat | 'esm';

export type NodeFormat =
| CommonFormat
Expand Down
12 changes: 6 additions & 6 deletions packages/packemon/tests/Package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe('Package', () => {

await pkg.build({ addEngines: true }, config);

expect(pkg.json.engines).toEqual({ node: '>=16.12.0' });
expect(pkg.json.engines).toEqual({ node: '>=18.12.0' });
});

it('uses oldest `node` build', async () => {
Expand All @@ -183,7 +183,7 @@ describe('Package', () => {

await pkg.build({ addEngines: true }, config);

expect(pkg.json.engines).toEqual({ node: '>=14.15.0' });
expect(pkg.json.engines).toEqual({ node: '>=16.12.0' });
});

it('merges with existing engines', async () => {
Expand All @@ -199,7 +199,7 @@ describe('Package', () => {

expect(pkg.json.engines).toEqual({
packemon: '*',
node: '>=16.12.0',
node: '>=18.12.0',
});
});
});
Expand Down Expand Up @@ -1334,7 +1334,7 @@ describe('Package', () => {
bundle: true,
externals: [],
features: COMMON_FEATURES,
formats: ['lib'],
formats: ['esm'],
inputs: {},
platform: 'native',
namespace: '',
Expand Down Expand Up @@ -1478,7 +1478,7 @@ describe('Package', () => {
bundle: true,
externals: [],
features: COMMON_FEATURES,
formats: ['lib'],
formats: ['esm'],
inputs: {},
platform: 'native',
namespace: '',
Expand Down Expand Up @@ -1592,7 +1592,7 @@ describe('Package', () => {
expect(() => {
pkg.setConfigs([
{
format: 'esm',
format: 'mjs',
platform: 'native',
},
]);
Expand Down
2 changes: 1 addition & 1 deletion packages/packemon/tests/__snapshots__/Package.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports[`Package > setConfigs() > errors if invalid format is provided for \`bro

exports[`Package > setConfigs() > errors if invalid format is provided for \`native\` platform 1`] = `
[OptimalError: The following validations have failed for \`flag-common\`:
- Invalid field "format". String must be one of: lib. Received "esm".]
- Invalid field "format". String must be one of: lib, esm. Received "mjs".]
`;

exports[`Package > setConfigs() > errors if invalid format is provided for \`node\` platform 1`] = `
Expand Down
130 changes: 130 additions & 0 deletions packages/packemon/tests/__snapshots__/outputs.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9029,6 +9029,37 @@ exports.button = button;
"
`;

exports[`Outputs (babel) > bundle with assets > bundles all files and references assets (native, esm) > ../assets/fonts-4e5dc96c.css 1`] = `
"@font-face {
}
"
`;

exports[`Outputs (babel) > bundle with assets > bundles all files and references assets (native, esm) > ../assets/globals-107ab52e.css 1`] = `
"html {
}
"
`;

exports[`Outputs (babel) > bundle with assets > bundles all files and references assets (native, esm) > ../assets/styles-b11c3a83.css 1`] = `
".button {
}
"
`;

exports[`Outputs (babel) > bundle with assets > bundles all files and references assets (native, esm) > esm/index.js 1`] = `
"// Bundled with Packemon: https://packemon.dev
// Platform: native, Support: stable, Format: esm

import '../assets/globals-107ab52e.css';
import '../assets/fonts-4e5dc96c.css';
import '../assets/styles-b11c3a83.css';
function button() {}
export { button };
//# sourceMappingURL=index.js.map
"
`;

exports[`Outputs (babel) > bundle with assets > bundles all files and references assets (native, lib) > ../assets/fonts-4e5dc96c.css 1`] = `
"@font-face {
}
Expand Down Expand Up @@ -9541,6 +9572,40 @@ exports.button = index.button;
"
`;

exports[`Outputs (babel) > no bundle with assets > creates individual files and references assets (native, esm) > ../assets/fonts-4e5dc96c.css 1`] = `
"@font-face {
}
"
`;

exports[`Outputs (babel) > no bundle with assets > creates individual files and references assets (native, esm) > ../assets/globals-107ab52e.css 1`] = `
"html {
}
"
`;

exports[`Outputs (babel) > no bundle with assets > creates individual files and references assets (native, esm) > ../assets/styles-b11c3a83.css 1`] = `
".button {
}
"
`;

exports[`Outputs (babel) > no bundle with assets > creates individual files and references assets (native, esm) > esm/button/index.js 1`] = `
"import '../../assets/styles-b11c3a83.css';
function button() {}
export { button };
//# sourceMappingURL=index.js.map
"
`;

exports[`Outputs (babel) > no bundle with assets > creates individual files and references assets (native, esm) > esm/index.js 1`] = `
"import '../assets/globals-107ab52e.css';
import '../assets/fonts-4e5dc96c.css';
export { button } from './button/index.js';
//# sourceMappingURL=index.js.map
"
`;

exports[`Outputs (babel) > no bundle with assets > creates individual files and references assets (native, lib) > ../assets/fonts-4e5dc96c.css 1`] = `
"@font-face {
}
Expand Down Expand Up @@ -18492,6 +18557,37 @@ exports.button = button;
"
`;

exports[`Outputs (swc) > bundle with assets > bundles all files and references assets (native, esm) > ../assets/fonts-4e5dc96c.css 1`] = `
"@font-face {
}
"
`;

exports[`Outputs (swc) > bundle with assets > bundles all files and references assets (native, esm) > ../assets/globals-107ab52e.css 1`] = `
"html {
}
"
`;

exports[`Outputs (swc) > bundle with assets > bundles all files and references assets (native, esm) > ../assets/styles-b11c3a83.css 1`] = `
".button {
}
"
`;

exports[`Outputs (swc) > bundle with assets > bundles all files and references assets (native, esm) > esm/index.js 1`] = `
"// Bundled with Packemon: https://packemon.dev
// Platform: native, Support: stable, Format: esm

import '../assets/globals-107ab52e.css';
import '../assets/fonts-4e5dc96c.css';
import '../assets/styles-b11c3a83.css';
function button() {}
export { button };
//# sourceMappingURL=index.js.map
"
`;

exports[`Outputs (swc) > bundle with assets > bundles all files and references assets (native, lib) > ../assets/fonts-4e5dc96c.css 1`] = `
"@font-face {
}
Expand Down Expand Up @@ -19004,6 +19100,40 @@ exports.button = index.button;
"
`;

exports[`Outputs (swc) > no bundle with assets > creates individual files and references assets (native, esm) > ../assets/fonts-4e5dc96c.css 1`] = `
"@font-face {
}
"
`;

exports[`Outputs (swc) > no bundle with assets > creates individual files and references assets (native, esm) > ../assets/globals-107ab52e.css 1`] = `
"html {
}
"
`;

exports[`Outputs (swc) > no bundle with assets > creates individual files and references assets (native, esm) > ../assets/styles-b11c3a83.css 1`] = `
".button {
}
"
`;

exports[`Outputs (swc) > no bundle with assets > creates individual files and references assets (native, esm) > esm/button/index.js 1`] = `
"import '../../assets/styles-b11c3a83.css';
function button() {}
export { button };
//# sourceMappingURL=index.js.map
"
`;

exports[`Outputs (swc) > no bundle with assets > creates individual files and references assets (native, esm) > esm/index.js 1`] = `
"import '../assets/globals-107ab52e.css';
import '../assets/fonts-4e5dc96c.css';
export { button } from './button/index.js';
//# sourceMappingURL=index.js.map
"
`;

exports[`Outputs (swc) > no bundle with assets > creates individual files and references assets (native, lib) > ../assets/fonts-4e5dc96c.css 1`] = `
"@font-face {
}
Expand Down
Loading
Loading