Skip to content

Commit

Permalink
add rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
drcmda committed Jul 11, 2023
1 parent 17142cc commit 7878335
Show file tree
Hide file tree
Showing 4 changed files with 3,843 additions and 32 deletions.
20 changes: 18 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "6.2.6",
"description": "GLTF to JSX converter",
"scripts": {
"build": "rollup -c",
"test": "node src/test"
},
"type": "module",
Expand Down Expand Up @@ -31,7 +32,8 @@
"bin": {
"gltfjsx": "./cli.js"
},
"main": "./src/utils/exports.js",
"main": "dist/index.cjs",
"module": "dist/index.js",
"engines": {
"node": ">=16"
},
Expand All @@ -55,10 +57,24 @@
"sharp": "^0.32.1"
},
"devDependencies": {
"@babel/core": "7.16.0",
"@babel/plugin-proposal-class-properties": "^7.16.0",
"@babel/plugin-transform-modules-commonjs": "7.16.0",
"@babel/plugin-transform-parameters": "7.16.0",
"@babel/plugin-transform-runtime": "7.16.0",
"@babel/plugin-transform-template-literals": "7.16.0",
"@babel/preset-env": "7.16.0",
"@babel/preset-react": "7.16.0",
"@babel/preset-typescript": "^7.16.0",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-node-resolve": "^13.0.6",
"chalk": "^5.2.0",
"fast-glob": "^3.2.12",
"fs-extra": "^11.1.1",
"lint-staged": "^13.2.2"
"lint-staged": "^13.2.2",
"rollup": "^2.59.0",
"rollup-plugin-size-snapshot": "^0.12.0",
"rollup-plugin-terser": "^7.0.2"
},
"prettier": {
"semi": false,
Expand Down
47 changes: 47 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import path from 'path'
import babel from '@rollup/plugin-babel'
import resolve from '@rollup/plugin-node-resolve'

const root = process.platform === 'win32' ? path.resolve('/') : '/'
const external = (id) => !id.startsWith('.') && !id.startsWith(root)
const extensions = ['.js', '.jsx', '.ts', '.tsx', '.json']

const getBabelOptions = ({ useESModules }) => ({
babelrc: false,
extensions,
exclude: '**/node_modules/**',
babelHelpers: 'runtime',
presets: [
[
'@babel/preset-env',
{
include: [
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-numeric-separator',
'@babel/plugin-proposal-logical-assignment-operators',
],
bugfixes: true,
loose: true,
modules: false,
targets: '> 1%, not dead, not ie 11, not op_mini all',
},
],
],
plugins: [['@babel/transform-runtime', { regenerator: false, useESModules }]],
})

export default [
{
input: `./src/utils/exports.js`,
output: { file: `dist/index.js`, format: 'esm' },
external,
plugins: [babel(getBabelOptions({ useESModules: true })), resolve({ extensions })],
},
{
input: `./src/utils/exports.js`,
output: { file: `dist/index.cjs.js`, format: 'cjs' },
external,
plugins: [babel(getBabelOptions({ useESModules: false })), resolve({ extensions })],
},
]
4 changes: 2 additions & 2 deletions src/utils/parser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as THREE from 'three'
import prettier from 'prettier'
import babelParser from 'prettier/parser-babel.js'
import * as prettier from "prettier";
import babelParser from "prettier/parser-babel.js";
import isVarName from './isVarName.js'

function parse(gltf, { fileName = 'model', ...options } = {}) {
Expand Down
Loading

0 comments on commit 7878335

Please sign in to comment.