Skip to content

Commit

Permalink
add closure compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
drcmda committed Jul 27, 2020
1 parent 891b0e5 commit aa28048
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
4 changes: 2 additions & 2 deletions examples/src/demos/index.js
Expand Up @@ -15,7 +15,7 @@ const Refraction = { descr: '', tags: [], Component: lazy(() => import('./Refrac
const Test = { descr: '', tags: [], Component: lazy(() => import('./dev/Test')), dev: true }
const Viewcube = { descr: '', tags: [], Component: lazy(() => import('./dev/Viewcube')), dev: true }
const Concurrent = { descr: '', tags: [], Component: lazy(() => import('./dev/Concurrent')), dev: true }
const Dom = { descr: '', tags: [], Component: lazy(() => import('./dev/Dom')), dev: true }
//const Dom = { descr: '', tags: [], Component: lazy(() => import('./dev/Dom')), dev: true }
//const SVGRenderer = { descr: '', tags: [], Component: lazy(() => import('./dev/SVGRenderer')), dev: true }
//const CSS2DRenderer = { descr: '', tags: [], Component: lazy(() => import('./dev/CSS2DRenderer')), dev: true }
//const CSS3DRenderer = { descr: '', tags: [], Component: lazy(() => import('./dev/CSS3DRenderer')), dev: true }
Expand Down Expand Up @@ -72,7 +72,7 @@ export {
//SVGRenderer,
//CSS2DRenderer,
//CSS3DRenderer,
Dom,
//Dom,
Concurrent,
Viewcube,
Test,
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -84,6 +84,7 @@
"@babel/preset-env": "7.10.4",
"@babel/preset-react": "7.10.4",
"@babel/preset-typescript": "^7.10.4",
"@rollup/plugin-commonjs": "^14.0.0",
"@types/jest": "^26.0.7",
"@types/lodash-es": "^4.17.3",
"@types/react": "^16.9.43",
Expand Down
16 changes: 13 additions & 3 deletions rollup.config.js
Expand Up @@ -4,9 +4,14 @@ import babel from 'rollup-plugin-babel'
import resolve from 'rollup-plugin-node-resolve'
import json from 'rollup-plugin-json'
import { sizeSnapshot } from 'rollup-plugin-size-snapshot'
import compiler from '@ampproject/rollup-plugin-closure-compiler'
import commonjs from '@rollup/plugin-commonjs'

const root = process.platform === 'win32' ? path.resolve('/') : '/'
const external = id => !id.startsWith('.') && !id.startsWith(root)
const external = (id) => {
if (id.startsWith('react-reconciler')) return false
return !id.startsWith('.') && !id.startsWith(root)
}
const extensions = ['.js', '.jsx', '.ts', '.tsx', '.json']

const getBabelOptions = ({ useESModules }, targets) => ({
Expand Down Expand Up @@ -43,11 +48,15 @@ function createConfig(entry, out) {
external,
plugins: [
json(),
commonjs(),
babel(getBabelOptions({ useESModules: true }, '>1%, not dead, not ie 11, not op_mini all')),
sizeSnapshot(),
resolve({ extensions }),
targetTypings(entry, out),
//compiler(),
/*compiler({
compilation_level: 'SIMPLE_OPTIMIZATIONS',
jscomp_off: 'checkVars',
}),*/
sizeSnapshot(),
],
},
{
Expand All @@ -56,6 +65,7 @@ function createConfig(entry, out) {
external,
plugins: [
json(),
commonjs(),
babel(getBabelOptions({ useESModules: false })),
sizeSnapshot(),
resolve({ extensions }),
Expand Down
14 changes: 8 additions & 6 deletions src/renderer.tsx
@@ -1,6 +1,8 @@
import * as THREE from 'three'
import { Layers, Color, Texture, sRGBEncoding } from 'three'
import React from 'react'
import Reconciler from 'react-reconciler'
//@ts-ignore
import Reconciler from 'react-reconciler/cjs/react-reconciler.production.min'
import { unstable_now as now, unstable_IdlePriority as idlePriority, unstable_runWithPriority as run } from 'scheduler'
import { CanvasContext } from './canvas'

Expand Down Expand Up @@ -89,7 +91,7 @@ export function renderGl(
let running = false
function renderLoop(timestamp: number) {
running = true

let repeat = 0
let i
// Run global effects
Expand Down Expand Up @@ -225,7 +227,7 @@ export function applyProps(instance: any, newProps: any, oldProps: any = {}, acc
}
// Special treatment for objects with support for set/copy
const isColorManagement = instance.__container?.__state.current.colorManagement
if (target && target.set && (target.copy || target instanceof THREE.Layers)) {
if (target && target.set && (target.copy || target instanceof Layers)) {
// If value is an array it has got to be the set function
if (Array.isArray(value)) {
target.set(...value)
Expand All @@ -246,7 +248,7 @@ export function applyProps(instance: any, newProps: any, oldProps: any = {}, acc

// Auto-convert sRGB colors, for now ...
// https://github.com/react-spring/react-three-fiber/issues/344
if (isColorManagement && target instanceof THREE.Color) {
if (isColorManagement && target instanceof Color) {
target.convertSRGBToLinear()
}
}
Expand All @@ -256,8 +258,8 @@ export function applyProps(instance: any, newProps: any, oldProps: any = {}, acc

// Auto-convert sRGB textures, for now ...
// https://github.com/react-spring/react-three-fiber/issues/344
if (isColorManagement && root[key] instanceof THREE.Texture) {
root[key].encoding = THREE.sRGBEncoding
if (isColorManagement && root[key] instanceof Texture) {
root[key].encoding = sRGBEncoding
}
}

Expand Down
13 changes: 13 additions & 0 deletions yarn.lock
Expand Up @@ -1268,6 +1268,19 @@
resolved "https://registry.yarnpkg.com/@juggle/resize-observer/-/resize-observer-3.2.0.tgz#5e0b448d27fe3091bae6216456512c5904d05661"
integrity sha512-fsLxt0CHx2HCV9EL8lDoVkwHffsA0snUpddYjdLyXcG5E41xaamn9ZyQqOE9TUJdrRlH8/hjIf+UdOdDeKCUgg==

"@rollup/plugin-commonjs@^14.0.0":
version "14.0.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-14.0.0.tgz#4285f9ec2db686a31129e5a2b415c94aa1f836f0"
integrity sha512-+PSmD9ePwTAeU106i9FRdc+Zb3XUWyW26mo5Atr2mk82hor8+nPwkztEjFo8/B1fJKfaQDg9aM2bzQkjhi7zOw==
dependencies:
"@rollup/pluginutils" "^3.0.8"
commondir "^1.0.1"
estree-walker "^1.0.1"
glob "^7.1.2"
is-reference "^1.1.2"
magic-string "^0.25.2"
resolve "^1.11.0"

"@rollup/plugin-replace@^2.3.2":
version "2.3.3"
resolved "https://registry.yarnpkg.com/@rollup/plugin-replace/-/plugin-replace-2.3.3.tgz#cd6bae39444de119f5d905322b91ebd4078562e7"
Expand Down

0 comments on commit aa28048

Please sign in to comment.