Skip to content

Commit

Permalink
breaking: Drop Node.js v10/12 support and shift Node.js/npm support v…
Browse files Browse the repository at this point in the history
…ersions. (#113)

* Drop node 12.

* Shift numbers.

* Update tests.

* Bump down a bit.
  • Loading branch information
milesj committed Apr 20, 2022
1 parent 46a70ac commit 38340df
Show file tree
Hide file tree
Showing 23 changed files with 156 additions and 236 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [12, 14, 16, 17]
node-version: [14, 16, 17]
fail-fast: true
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ configured to support all formats.
## Requirements

- Linux, OSX, Windows
- Node 12.17+
- Node 14.15+

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"website"
],
"engines": {
"node": ">=12.17.0",
"node": ">=14.19.0",
"npm": ">=6.13.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-cjs-esm-interop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = {
## Requirements

- Linux, OSX, Windows
- Node 12.17+
- Node 14.15+

## Transforms

Expand Down
4 changes: 2 additions & 2 deletions packages/babel-plugin-cjs-esm-interop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"src/**/*.{ts,tsx,json}"
],
"engines": {
"node": ">=12.17.0",
"npm": ">=6.13.0"
"node": ">=14.15.0",
"npm": ">=6.14.0"
},
"packemon": {
"format": "lib",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-conditional-invariant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ module.exports = {
## Requirements

- Linux, OSX, Windows
- Node 12.17+
- Node 14.15+
4 changes: 2 additions & 2 deletions packages/babel-plugin-conditional-invariant/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"src/**/*.{ts,tsx,json}"
],
"engines": {
"node": ">=12.17.0",
"npm": ">=6.13.0"
"node": ">=14.15.0",
"npm": ">=6.14.0"
},
"packemon": {
"format": "lib",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-env-constants/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ declare global {
## Requirements

- Linux, OSX, Windows
- Node 12.17+
- Node 14.15+
4 changes: 2 additions & 2 deletions packages/babel-plugin-env-constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"src/**/*.{ts,tsx,json}"
],
"engines": {
"node": ">=12.17.0",
"npm": ">=6.13.0"
"node": ">=14.15.0",
"npm": ">=6.14.0"
},
"packemon": {
"format": "lib",
Expand Down
2 changes: 1 addition & 1 deletion packages/packemon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ configured to support all formats.
## Requirements

- Linux, OSX, Windows
- Node 12.17+
- Node 14.15+

## Documentation

Expand Down
4 changes: 2 additions & 2 deletions packages/packemon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
}
},
"engines": {
"node": ">=12.17.0",
"npm": ">=6.13.0"
"node": ">=14.15.0",
"npm": ">=6.14.0"
},
"packemon": {
"inputs": {
Expand Down
13 changes: 0 additions & 13 deletions packages/packemon/src/babel/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ export function getBabelInputConfig(
presets.push([
resolve('@babel/preset-react'),
{
development: __DEV__,
runtime: features.react,
throwIfNamespace: true,
},
Expand Down Expand Up @@ -187,18 +186,6 @@ export function getBabelOutputConfig(
// PLUGINS

if (platform === 'browser' || platform === 'native') {
// While modern browsers support these features, Node.js does not,
// which results in failing builds trying to parse the syntax.
// Let's only apply this for the lib format, but allow it for esm.
// TODO: Drop in Node 12+
if (format === 'lib') {
plugins.push(
resolveFromBabel('@babel/plugin-proposal-logical-assignment-operators'),
resolveFromBabel('@babel/plugin-proposal-nullish-coalescing-operator'),
resolveFromBabel('@babel/plugin-proposal-optional-chaining'),
);
}

// Both browsers and Node.js support these features outside of legacy targets
if (support === 'legacy') {
plugins.push(
Expand Down
16 changes: 8 additions & 8 deletions packages/packemon/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,17 @@ export const NATIVE_TARGETS: { [K in Support]: string } = {

// Based on LTS schedule: https://nodejs.org/en/about/releases/
export const NODE_SUPPORTED_VERSIONS: { [K in Support]: string } = {
legacy: '10.3.0',
stable: '12.17.0', // ESM support not behind a flag
current: '14.16.0', // Includes security fixes
experimental: '16.0.0',
legacy: '12.22.0',
stable: '14.15.0', // LTS support started
current: '16.12.0', // ESM loader hooks
experimental: '18.0.0',
};

export const NPM_SUPPORTED_VERSIONS: { [K in Support]: string[] | string } = {
legacy: '6.1.0',
stable: '6.13.0',
current: ['6.14.0', '7.0.0'],
experimental: '7.0.0',
legacy: '6.14.0',
stable: '6.14.0',
current: '8.1.0',
experimental: '8.5.0',
};

// Based on browserslist: https://github.com/browserslist/browserslist
Expand Down
12 changes: 0 additions & 12 deletions packages/packemon/src/swc/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,6 @@ export function getSwcOutputConfig(
...getPlatformEnvOptions(platform, support, format),
};

// While modern browsers support these features, Node.js does not,
// which results in failing builds trying to parse the syntax.
// Let's only apply this for the lib format, but allow it for esm.
// TODO: Drop in Node 12+
if ((platform === 'browser' || platform === 'native') && format === 'lib') {
env.include = [
'proposal-logical-assignment-operators',
'proposal-nullish-coalescing-operator',
'proposal-optional-chaining',
];
}

const module: ModuleConfig = {
type: getModuleConfigType(format),
// @ts-expect-error Not typed
Expand Down
8 changes: 4 additions & 4 deletions packages/packemon/tests/Package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ describe('Package', () => {

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

expect(pkg.packageJson.engines).toEqual({ node: '>=12.17.0', npm: '>=6.13.0' });
expect(pkg.packageJson.engines).toEqual({ node: '>=14.15.0', npm: '>=6.14.0' });
});

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

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

expect(pkg.packageJson.engines).toEqual({ node: '>=10.3.0', npm: '>=6.1.0' });
expect(pkg.packageJson.engines).toEqual({ node: '>=12.22.0', npm: '>=6.14.0' });
});

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

expect(pkg.packageJson.engines).toEqual({
packemon: '*',
node: '>=12.17.0',
npm: '>=6.13.0',
node: '>=14.15.0',
npm: '>=6.14.0',
});
});
});
Expand Down
43 changes: 16 additions & 27 deletions packages/packemon/tests/babel/__snapshots__/config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Object {
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "12.17.0",
"node": "14.15.0",
},
"useBuiltIns": false,
},
Expand Down Expand Up @@ -153,7 +153,7 @@ Object {
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "12.17.0",
"node": "14.15.0",
},
"useBuiltIns": false,
},
Expand Down Expand Up @@ -241,7 +241,6 @@ Array [
Array [
"@babel/preset-react",
Object {
"development": true,
"runtime": "classic",
"throwIfNamespace": true,
},
Expand All @@ -254,7 +253,6 @@ Array [
Array [
"@babel/preset-react",
Object {
"development": true,
"runtime": "automatic",
"throwIfNamespace": true,
},
Expand Down Expand Up @@ -387,9 +385,6 @@ Object {
"strictMode": undefined,
},
"plugins": Array [
"@babel/plugin-proposal-logical-assignment-operators",
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-optional-chaining",
"babel-plugin-conditional-invariant",
"babel-plugin-env-constants",
"babel-plugin-example",
Expand Down Expand Up @@ -774,7 +769,7 @@ Array [
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "14.16.0",
"node": "16.12.0",
},
"useBuiltIns": false,
},
Expand All @@ -796,7 +791,7 @@ Array [
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "16.0.0",
"node": "18.0.0",
},
"useBuiltIns": false,
},
Expand All @@ -817,7 +812,7 @@ Array [
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "10.3.0",
"node": "12.22.0",
},
"useBuiltIns": false,
},
Expand All @@ -838,7 +833,7 @@ Array [
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "12.17.0",
"node": "14.15.0",
},
"useBuiltIns": false,
},
Expand All @@ -860,7 +855,7 @@ Array [
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "14.16.0",
"node": "16.12.0",
},
"useBuiltIns": false,
},
Expand All @@ -882,7 +877,7 @@ Array [
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "16.0.0",
"node": "18.0.0",
},
"useBuiltIns": false,
},
Expand All @@ -903,7 +898,7 @@ Array [
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "10.3.0",
"node": "12.22.0",
},
"useBuiltIns": false,
},
Expand All @@ -924,7 +919,7 @@ Array [
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "12.17.0",
"node": "14.15.0",
},
"useBuiltIns": false,
},
Expand All @@ -946,7 +941,7 @@ Array [
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "14.16.0",
"node": "16.12.0",
},
"useBuiltIns": false,
},
Expand All @@ -968,7 +963,7 @@ Array [
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "16.0.0",
"node": "18.0.0",
},
"useBuiltIns": false,
},
Expand All @@ -989,7 +984,7 @@ Array [
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "10.3.0",
"node": "12.22.0",
},
"useBuiltIns": false,
},
Expand All @@ -1010,7 +1005,7 @@ Array [
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "12.17.0",
"node": "14.15.0",
},
"useBuiltIns": false,
},
Expand All @@ -1031,9 +1026,6 @@ Object {
"strictMode": undefined,
},
"plugins": Array [
"@babel/plugin-proposal-logical-assignment-operators",
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-optional-chaining",
"babel-plugin-conditional-invariant",
"babel-plugin-env-constants",
],
Expand Down Expand Up @@ -1076,9 +1068,6 @@ Object {
"strictMode": undefined,
},
"plugins": Array [
"@babel/plugin-proposal-logical-assignment-operators",
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-optional-chaining",
"babel-plugin-conditional-invariant",
"babel-plugin-env-constants",
],
Expand Down Expand Up @@ -1154,7 +1143,7 @@ Object {
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "14.16.0",
"node": "16.12.0",
},
"useBuiltIns": false,
},
Expand Down Expand Up @@ -1213,7 +1202,7 @@ Object {
"shippedProposals": true,
"spec": true,
"targets": Object {
"node": "16.0.0",
"node": "18.0.0",
},
"useBuiltIns": false,
},
Expand Down
Loading

0 comments on commit 38340df

Please sign in to comment.