Skip to content

Commit

Permalink
feat: use babel, remove cjs build
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac-mason committed May 1, 2024
1 parent 69809e9 commit 22e0978
Show file tree
Hide file tree
Showing 19 changed files with 1,214 additions and 109 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v2

- name: Setup Node.js 18.x
- name: Setup Node.js 22.x
uses: actions/setup-node@v2
with:
node-version: 18.x
node-version: 22.x

- name: Install Dependencies
run: yarn
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v2

- name: Setup Node.js 18.x
- name: Setup Node.js 22.x
uses: actions/setup-node@v2
with:
node-version: 18.x
node-version: 22.x

- name: Install Dependencies
run: yarn
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.12.1
v22.0.0
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The `recast-navigation-js` repository is structured as a yarn monorepo. You will

### Node Installation

**This project uses node 18.**
**This project uses node 22.**

If you don't already use a node version manager. Give nvm a try if you don't already have one.

Expand Down
2 changes: 1 addition & 1 deletion examples/node-cjs-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"description": "example of using recast-navigation in node",
"scripts": {
"start": "node index.cjs"
"start": "node --experimental-require-module index.cjs"
},
"author": "",
"license": "ISC",
Expand Down
8 changes: 6 additions & 2 deletions packages/recast-navigation-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"bugs": {
"url": "https://github.com/isaac-mason/recast-navigation-js/issues"
},
"main": "./dist/index.cjs",
"type": "module",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
Expand All @@ -29,8 +30,11 @@
"@recast-navigation/wasm": "0.27.0"
},
"devDependencies": {
"@babel/core": "^7.24.4",
"@babel/core": "^7.24.5",
"@babel/preset-env": "^7.24.5",
"@babel/preset-typescript": "^7.24.1",
"@isaac-mason/eslint-config-typescript": "^0.0.5",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.4.3",
Expand Down
33 changes: 23 additions & 10 deletions packages/recast-navigation-core/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import path from 'path';
import filesize from 'rollup-plugin-filesize';

const babelOptions = {
babelrc: false,
extensions: ['.ts'],
exclude: '**/node_modules/**',
babelHelpers: 'bundled',
presets: [
[
'@babel/preset-env',
{
loose: true,
modules: false,
targets: '>1%, not dead, not ie 11, not op_mini all',
},
],
'@babel/preset-typescript',
],
};

export default [
{
input: `./src/index.ts`,
Expand All @@ -15,22 +34,16 @@ export default [
sourcemap: true,
exports: 'named',
},
{
file: `dist/index.cjs`,
format: 'cjs',
sourcemap: true,
exports: 'named',
},
],
plugins: [
terser(),
nodeResolve(),
resolve(),
commonjs(),
typescript({
tsconfig: path.resolve(__dirname, `tsconfig.json`),
sourceMap: true,
inlineSources: true,
emitDeclarationOnly: true,
}),
babel(babelOptions),
filesize(),
],
},
Expand Down
7 changes: 6 additions & 1 deletion packages/recast-navigation-generators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"bugs": {
"url": "https://github.com/isaac-mason/recast-navigation-js/issues"
},
"main": "./dist/index.cjs",
"type": "module",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
Expand All @@ -30,7 +31,11 @@
"@recast-navigation/wasm": "0.27.0"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/preset-env": "^7.24.5",
"@babel/preset-typescript": "^7.24.1",
"@isaac-mason/eslint-config-typescript": "^0.0.5",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.4.3",
Expand Down
33 changes: 23 additions & 10 deletions packages/recast-navigation-generators/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import path from 'path';
import filesize from 'rollup-plugin-filesize';

const babelOptions = {
babelrc: false,
extensions: ['.ts'],
exclude: '**/node_modules/**',
babelHelpers: 'bundled',
presets: [
[
'@babel/preset-env',
{
loose: true,
modules: false,
targets: '>1%, not dead, not ie 11, not op_mini all',
},
],
'@babel/preset-typescript',
],
};

export default [
{
input: `./src/index.ts`,
Expand All @@ -16,22 +35,16 @@ export default [
sourcemap: true,
exports: 'named',
},
{
file: `dist/index.cjs`,
format: 'cjs',
sourcemap: true,
exports: 'named',
}
],
plugins: [
terser(),
nodeResolve(),
resolve(),
commonjs(),
typescript({
tsconfig: path.resolve(__dirname, `tsconfig.json`),
sourceMap: true,
inlineSources: true,
emitDeclarationOnly: true,
}),
babel(babelOptions),
filesize(),
],
},
Expand Down
7 changes: 6 additions & 1 deletion packages/recast-navigation-three/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"bugs": {
"url": "https://github.com/isaac-mason/recast-navigation-js/issues"
},
"main": "./dist/index.cjs",
"type": "module",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
Expand All @@ -34,7 +35,11 @@
"three": "0.x.x"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/preset-env": "^7.24.5",
"@babel/preset-typescript": "^7.24.1",
"@isaac-mason/eslint-config-typescript": "^0.0.5",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.4.3",
Expand Down
39 changes: 28 additions & 11 deletions packages/recast-navigation-three/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,54 @@
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import path from 'path';
import filesize from 'rollup-plugin-filesize';

const babelOptions = {
babelrc: false,
extensions: ['.ts'],
exclude: '**/node_modules/**',
babelHelpers: 'bundled',
presets: [
[
'@babel/preset-env',
{
loose: true,
modules: false,
targets: '>1%, not dead, not ie 11, not op_mini all',
},
],
'@babel/preset-typescript',
],
};

export default [
{
input: `./src/index.ts`,
external: ['@recast-navigation/core', '@recast-navigation/generators', 'three'],
external: [
'@recast-navigation/core',
'@recast-navigation/generators',
'three',
],
output: [
{
file: `dist/index.mjs`,
format: 'es',
sourcemap: true,
exports: 'named',
},
{
file: `dist/index.cjs`,
format: 'cjs',
sourcemap: true,
exports: 'named',
}
],
plugins: [
terser(),
nodeResolve(),
resolve(),
commonjs(),
typescript({
tsconfig: path.resolve(__dirname, `tsconfig.json`),
sourceMap: true,
inlineSources: true,
emitDeclarationOnly: true,
}),
babel(babelOptions),
filesize(),
],
},
Expand Down
2 changes: 1 addition & 1 deletion packages/recast-navigation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Demonstrations of how to use the library in different environments (such as Node

## Installation

This package ships as both ECMAScript modules and CJS, and is compatible with Node.js and browser environments.
`recast-navigation-js` ships as ECMAScript modules, and is compatible with Node.js and browser environments.

**NPM**

Expand Down
14 changes: 9 additions & 5 deletions packages/recast-navigation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,25 @@
"bugs": {
"url": "https://github.com/isaac-mason/recast-navigation-js/issues"
},
"main": "./index.cjs",
"type": "module",
"main": "./index.mjs",
"module": "./index.mjs",
"types": "./index.d.ts",
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.mjs",
"require": "./index.cjs"
"default": "./index.mjs"
},
"./generators": {
"types": "./generators.d.ts",
"import": "./generators.mjs",
"require": "./generators.cjs"
"default": "./generators.mjs"
},
"./three": {
"types": "./three.d.ts",
"import": "./three.mjs",
"require": "./index.cjs"
"default": "./three.mjs"
}
},
"files": [
Expand Down Expand Up @@ -77,12 +78,15 @@
"@recast-navigation/three": "0.27.0"
},
"devDependencies": {
"@babel/core": "^7.24.4",
"@babel/core": "^7.24.5",
"@babel/preset-env": "^7.24.5",
"@babel/preset-typescript": "^7.24.1",
"@isaac-mason/eslint-config-typescript": "^0.0.5",
"@mdx-js/react": "^2.3.0",
"@pmndrs/assets": "^1.6.0",
"@react-three/drei": "^9.105.4",
"@react-three/fiber": "^8.15.12",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.4.3",
Expand Down
Loading

0 comments on commit 22e0978

Please sign in to comment.