Skip to content

Commit c9b0c6a

Browse files
feat: Build site using Vite (#3022)
* feat: Add vite & build scripts * fix: Tests * fix: Build process * fix: Update config * fix: Load files asynchronously * fix: Load ECS files asynchronously * fix: Tests * fix: Audit * fix: Update deps * fix: Remove working directory * fix: Remove unused deps * fix: Add repository tag to package.json * fix: Add dotenv * fix: Missing test dep * fix: Missing decentraland-ecs dependency and regenerate package-lock * fix: package.json and package-lock.json * fix: Icon * fix: Remove react-app * fix: Remove console log * fix: Tests and types * fix: Restore configureAnalytics * fix: Prebuild script * fix: Remove Vercel NODE_OPTIONS --------- Co-authored-by: Gabriel Diaz <[email protected]>
1 parent 1a4ae01 commit c9b0c6a

File tree

205 files changed

+21518
-58478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+21518
-58478
lines changed

.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
NODE_PATH=src
2-
REACT_APP_DCL_DEFAULT_ENV=dev
1+
VITE_REACT_APP_DCL_DEFAULT_ENV="dev"
2+
VITE_BASE_URL=""
3+
VITE_REACT_APP_WEBSITE_VERSION="0.0.0-development"
34
GEN_STATIC_LOCAL=true
4-
PUBLIC_URL=/
55

66
; Feature Flags
77
; These are controlled by a remote service, you can still enforce the flags by setting a

.eslintrc.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
"root": true,
33
"parser": "@typescript-eslint/parser",
44
"ignorePatterns": [
5+
"__mocks__/*",
56
"src/contracts/*",
67
"src/ecsScene/*",
7-
"scripts/*.js",
8+
"scripts/*.cjs",
89
"src/modules/project/export.ts",
910
"src/modules/analytics/sentry.ts",
1011
"src/modules/editor/base64.ts",
@@ -14,17 +15,21 @@
1415
"src/setupProxy.js"
1516
],
1617
"plugins": ["@typescript-eslint"],
17-
"extends": ["eslint:recommended", "react-app", "react-app/jest", "prettier"],
18+
"extends": ["eslint:recommended", "prettier"],
1819
"env": {
1920
"browser": true,
20-
"es6": true
21+
"es6": true,
22+
"jest": true
2123
},
2224
"rules": {
2325
"@typescript-eslint/ban-types": "error",
2426
"@typescript-eslint/ban-tslint-comment": "error",
2527
"@typescript-eslint/quotes": ["error", "single", { "avoidEscape": true }],
2628
"@typescript-eslint/no-misused-promises": ["error", { "checksVoidReturn": false }]
2729
},
30+
"parserOptions": {
31+
"project": ["./tsconfig.json"]
32+
},
2833
"overrides": [
2934
{
3035
"files": ["*.ts", "*.tsx"],
@@ -38,7 +43,8 @@
3843
"@typescript-eslint/no-unsafe-member-access": "off", // TODO: migrate code progressively to remove this line. https://typescript-eslint.io/rules/no-unsafe-member-access/
3944
"@typescript-eslint/no-unsafe-argument": "off", // TODO: migrate code progressively to remove this line. https://typescript-eslint.io/rules/no-unsafe-argument/
4045
"@typescript-eslint/no-explicit-any": "off", // TODO: migrate code progressively to remove this line. https://typescript-eslint.io/rules/no-explicit-any
41-
"@typescript-eslint/no-non-null-assertion": "off" // TODO: migrate code progressively to remove this line. https://typescript-eslint.io/rules/no-non-null-assertion
46+
"@typescript-eslint/no-non-null-assertion": "off", // TODO: migrate code progressively to remove this line. https://typescript-eslint.io/rules/no-non-null-assertion
47+
"@typescript-eslint/no-unsafe-enum-comparison": "off"
4248
},
4349
"parserOptions": {
4450
"project": ["./tsconfig.json"]

.github/workflows/audit.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ on: [push, pull_request]
55
jobs:
66
audit:
77
runs-on: ubuntu-latest
8-
98
steps:
10-
- name: Checkout repository
11-
uses: actions/checkout@v3
12-
13-
- name: Clean install dependencies
14-
run: npm ci
15-
9+
- uses: actions/checkout@master
10+
- name: Use Node.js 18.x
11+
uses: actions/[email protected]
12+
with:
13+
node-version: 18.x
14+
cache: 'npm'
15+
- name: Install
16+
run: npm i --legacy-peer-deps
1617
- name: Audit signatures
1718
run: npm audit signatures

.github/workflows/build-release.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,34 @@ on:
1010

1111
jobs:
1212
build-release:
13+
permissions:
14+
id-token: write
1315
runs-on: ubuntu-latest
1416
steps:
1517
- uses: actions/checkout@master
16-
- name: Use Node.js 16.x
17-
uses: actions/setup-node@v1
18+
- name: Use Node.js 18.x
19+
uses: actions/setup-node@v4.0.1
1820
with:
19-
node-version: 16.x
21+
node-version: 18.x
22+
cache: 'npm'
2023
- name: Set package.json version
2124
uses: menduz/oddish-action@master
2225
with:
2326
deterministic-snapshot: true
2427
only-update-versions: true
2528
- name: Install
26-
run: npm ci --legacy-peer-deps
29+
run: npm install --legacy-peer-deps
2730
env:
2831
HUSKY: 0
2932
- name: Build
3033
run: npm run build
3134
env:
3235
CI: 'false'
3336
NODE_PATH: 'src'
34-
NODE_OPTIONS: '--max-old-space-size=6144'
3537
- name: Publish
3638
uses: menduz/oddish-action@master
3739
with:
38-
cwd: './build'
40+
cwd: './dist'
3941
deterministic-snapshot: true
4042
registry-url: 'https://registry.npmjs.org'
4143
access: public

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
# production
1212
/build
13+
/dist
1314

1415
# misc
1516
.DS_Store

__mocks__/@babylonjs.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Export all old ECS math functions as mocks
2+
const Scalar = {
3+
toHex: i => {
4+
const str = i.toString(16)
5+
6+
if (i <= 15) {
7+
return ('0' + str).toUpperCase()
8+
}
9+
10+
return str.toUpperCase()
11+
}
12+
}
13+
14+
const decentralandEcs = {
15+
core: {
16+
Color4: function (r, g, b, a) {
17+
return {
18+
r,
19+
g,
20+
b,
21+
a,
22+
toHexString: () => {
23+
const intR = (r * 255) | 0
24+
const intG = (g * 255) | 0
25+
const intB = (b * 255) | 0
26+
const intA = (a * 255) | 0
27+
return '#' + Scalar.toHex(intR) + Scalar.toHex(intG) + Scalar.toHex(intB) + Scalar.toHex(intA)
28+
}
29+
}
30+
}
31+
}
32+
}
33+
34+
module.exports = decentralandEcs
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = () => undefined

public/index.html renamed to index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
5+
<link rel="shortcut icon" href="https://decentraland.org/images/icons/favicon-32x32.png" />
66
<meta
77
name="description"
88
content="Add your own 3D elements or choose from hundreds of pre-loaded items. Select, drag and drop them onto the canvas to create cool interactive scenes. No coding required, no design skills needed!"
@@ -32,8 +32,7 @@
3232
<meta itemprop="image" content="https://decentraland.org/images/logo.png" />
3333
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
3434
<meta name="theme-color" content="#000000" />
35-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
36-
<script type="text/javascript" src="%PUBLIC_URL%/config/hotjar.js"></script>
35+
<link rel="manifest" href="%VITE_BASE_URL%/manifest.json" />
3736

3837
<style>
3938
.loading-overlay {
@@ -81,5 +80,7 @@
8180
</div>
8281
<noscript>You need to enable JavaScript to run this app.</noscript>
8382
<div id="root"></div>
83+
<script type="module" src="/src/node.ts"></script>
84+
<script type="module" src="/src/index.tsx"></script>
8485
</body>
8586
</html>

jest.config.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* eslint-disable */
2+
import type { Config } from 'jest'
3+
4+
export default async (): Promise<Config> => {
5+
return {
6+
verbose: true,
7+
testEnvironment: 'jsdom',
8+
setupFiles: ['<rootDir>/src/tests/beforeSetupTests.ts'],
9+
setupFilesAfterEnv: ['<rootDir>/src/tests/afterSetupTest.ts'],
10+
transform: {
11+
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
12+
'<rootDir>/src/tests/config/fileTransformer.cjs',
13+
'^.+\\.(t|j)sx?$': [
14+
'@swc/jest',
15+
{
16+
jsc: {
17+
transform: {
18+
react: {
19+
runtime: 'automatic'
20+
}
21+
}
22+
}
23+
}
24+
]
25+
},
26+
testRegex: '(/__tests__/.*|(\\.|/)(spec))\\.[jt]sx?$',
27+
moduleNameMapper: {
28+
'^three/.*$': 'identity-obj-proxy',
29+
'decentraland-ecs': 'identity-obj-proxy',
30+
'^.*/modules/curations/collectionCuration/toasts.*$': 'identity-obj-proxy',
31+
'@dcl/ecs': 'identity-obj-proxy',
32+
canvas: 'identity-obj-proxy',
33+
'^.+?raw': 'identity-obj-proxy',
34+
'@dcl/single-sign-on-client': 'identity-obj-proxy',
35+
'\\.(css|less)$': 'identity-obj-proxy',
36+
'^components/(.*)$': '<rootDir>/src/components/$1',
37+
'^config$': '<rootDir>/src/config',
38+
'^contracts(/.*)$': '<rootDir>/src/contracts/$1',
39+
'^contracts$': '<rootDir>/src/contracts',
40+
'^ecsScene/(.*)$': '<rootDir>/src/ecsScene/$1',
41+
'^experiments/(.*)$': '<rootDir>/src/experiments/$1',
42+
'^icons/(.*)$': '<rootDir>/src/icons/$1',
43+
'^images/(.*)$': '<rootDir>/src/images/$1',
44+
'^lib/(.*)$': '<rootDir>/src/lib/$1',
45+
'^modules/(.*)$': '<rootDir>/src/modules/$1',
46+
'^routing/(.*)$': '<rootDir>/src/routing/$1',
47+
'^specs/(.*)$': '<rootDir>/src/specs/$1'
48+
},
49+
transformIgnorePatterns: ['node_modules/?!@0xsquid|eccrypto|libsodium-wrappers-sumo']
50+
}
51+
}

0 commit comments

Comments
 (0)