Skip to content

Build with Vite #1396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 66 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
7b550ea
build: First attempt to build with Vite
binh-dam-ibigroup May 6, 2025
984f10e
build(vite): Replace vite-yaml with esbuild-plugin-yaml
binh-dam-ibigroup May 7, 2025
050549a
build(vite): Correct js loading plugins
binh-dam-ibigroup May 7, 2025
8fc2494
build(vite): Convert config YML to JSON
binh-dam-ibigroup May 14, 2025
519792b
refactor: Fix config imports in top-level files.
binh-dam-ibigroup May 14, 2025
900ffaf
build(vite): Add plugin to import YAML files
binh-dam-ibigroup May 14, 2025
3d2b7f0
build(vite): Remove unused import
binh-dam-ibigroup May 15, 2025
b5b900c
style(app): Replace backtick in import
binh-dam-ibigroup May 15, 2025
219a30c
refactor(util/i18n): Import i18n yml files correctly.
binh-dam-ibigroup May 15, 2025
b0c2e73
refactor(util/i18n): Simplify i18n imports from OTP-RR.
binh-dam-ibigroup May 15, 2025
2995f26
refactor(util/i18n): Use Vite glob import for i18n content.
binh-dam-ibigroup May 15, 2025
0b68831
refactor(util/i18n): Import default from i18n yaml
binh-dam-ibigroup May 15, 2025
be357bb
refactor(api): Remove isomorphic fetch
binh-dam-ibigroup May 15, 2025
247497f
chore(deps): Upgrade object-hash to 3.0
binh-dam-ibigroup May 15, 2025
62ef2e7
refactor(app): Pass config.js fields correctly.
binh-dam-ibigroup May 15, 2025
5e79f2a
Merge branch 'dev' into build-with-vite
binh-dam-ibigroup May 15, 2025
58a38e0
ci(node-ci): Upgrade node to v22
binh-dam-ibigroup May 15, 2025
21377e3
build: Restore eslint script
binh-dam-ibigroup May 16, 2025
3a68a9e
build(esline): Remove extra eslint config file
binh-dam-ibigroup May 16, 2025
52b91a1
build: Restore eslint check in precommit
binh-dam-ibigroup May 16, 2025
8380027
build(eslint): Reuse existing eslint
binh-dam-ibigroup May 16, 2025
29c7c73
Merge branch 'dev' into build-with-vite
binh-dam-ibigroup May 16, 2025
5fc92fd
build(eslint): Reuse existing eslint version
binh-dam-ibigroup May 16, 2025
e16b860
refactor(i18n-loader): Extract code for loading i18n content.
binh-dam-ibigroup May 16, 2025
3730137
test(jest): Map i18n-loader to a mock file.
binh-dam-ibigroup May 16, 2025
6679e94
build: Use Vite and remove craco from yarn start and yarn build
binh-dam-ibigroup May 16, 2025
3ea5f2b
test(a11y): Move example files to example folder so they can be built.
binh-dam-ibigroup May 16, 2025
e2a5497
ci(percy): Use node 22 and update config yml paths.
binh-dam-ibigroup May 16, 2025
e9ae770
ci(percy): Download calltaker config to repo root
binh-dam-ibigroup May 16, 2025
de299a9
build(vite): Correctly import graphql files.
binh-dam-ibigroup May 16, 2025
d86aded
build: Support old blob package for call-taker
binh-dam-ibigroup May 19, 2025
6de3e1c
chore(yarn): Update yarn.lock
binh-dam-ibigroup May 19, 2025
0a18ded
test(serve): Replace serve with vite preview
binh-dam-ibigroup May 19, 2025
e02dc1b
build(vite): Stop forcing deps optimization.
binh-dam-ibigroup May 19, 2025
a7afef6
build(craco): Remove craco and webpack deps
binh-dam-ibigroup May 19, 2025
40cbc0e
build(babel): Remove unused Babel plugins
binh-dam-ibigroup May 19, 2025
9f34e61
test(jest): Remove react-scripts and explicitly add updated jest libs
binh-dam-ibigroup May 19, 2025
ad92a84
chore(test): Remove unused testing libs
binh-dam-ibigroup May 19, 2025
2a1ed3f
Revert "chore(test): Remove unused testing libs"
binh-dam-ibigroup May 20, 2025
802618a
Revert "test(jest): Remove react-scripts and explicitly add updated j…
binh-dam-ibigroup May 20, 2025
5cd4aea
build(vite): Support custom HTML files. Refactor custom file logic.
binh-dam-ibigroup May 20, 2025
a7dc3ed
build(vite): Tweak comments in vite.config.js
binh-dam-ibigroup May 20, 2025
7823f07
build(vite): Simplify custom file logic
binh-dam-ibigroup May 20, 2025
afd504b
chore(index.html): Remove index.html from repo root
binh-dam-ibigroup May 20, 2025
b603a50
chore(.gitignore): Ignore index.html
binh-dam-ibigroup May 20, 2025
128bc90
build(vite): Inject main script into index.html. Clean up main template.
binh-dam-ibigroup May 20, 2025
f1717b1
refactor(main.js): Remove obsolete comments
binh-dam-ibigroup May 20, 2025
482c016
build(vite): Tweak comments in vite.config
binh-dam-ibigroup May 20, 2025
5113867
refactor(main.js): Remove old IE11 math polyfill
binh-dam-ibigroup May 20, 2025
1da2446
build(vite): Correctly strip multiline comments from index.html
binh-dam-ibigroup May 20, 2025
321d5e6
refactor: Cleanup main and index templates
binh-dam-ibigroup May 20, 2025
0c55352
chore(deps): Remove globals
binh-dam-ibigroup May 20, 2025
b51429e
build(vite): Output js modules to dist directly (no subfolder)
binh-dam-ibigroup May 20, 2025
e939acf
build(vite): Add comment regarding assetsDir
binh-dam-ibigroup May 21, 2025
c0d1b43
build(vite): Fix comment typo
binh-dam-ibigroup May 21, 2025
e2d2774
build(vite): Watch custom files and copy to tmp if modified.
binh-dam-ibigroup May 29, 2025
08c6215
build(vite): Fix copying js from a folder.
binh-dam-ibigroup May 29, 2025
69c8cbd
build(vite): Watch custom files in dev mode only.
binh-dam-ibigroup May 29, 2025
b8f035a
Merge branch 'dev' into build-with-vite
binh-dam-ibigroup May 29, 2025
b9c6d43
Merge branch 'dev' into build-with-vite
daniel-heppner-ibigroup Jun 11, 2025
8350f8e
Merge branch 'dev' into build-with-vite
miles-grant-ibigroup Jun 12, 2025
60151c9
Merge branch 'dev' into build-with-vite
binh-dam-ibigroup Jun 16, 2025
a58aa35
Merge branch 'dev' into build-with-vite
binh-dam-ibigroup Jun 17, 2025
66f7777
build(.nvmrc): Use Node v22.
binh-dam-ibigroup Jun 17, 2025
76969a0
build(vite): Don't rename copied graphql files.
binh-dam-ibigroup Jun 17, 2025
901901b
Merge branch 'dev' into build-with-vite
binh-dam-ibigroup Jun 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
"@babel/preset-react"
],
"env": {
"development": {
"plugins": ["react-refresh/babel"]
},
"test": {
"presets": [["@babel/preset-env", { "targets": { "node": "current" } }]]
}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
with:
# This allows us to work with the repository during the lint step
fetch-depth: 2
- name: Use Node.js 21.x
- name: Use Node.js 22.x
uses: actions/setup-node@v1
with:
node-version: 21.x
node-version: 22.x
- name: Install npm packages using cache
uses: bahmutov/npm-install@v1
- name: Lint code
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/percy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ jobs:
with:
# This allows us to work with the repository during the lint step
fetch-depth: 2
- name: Use Node.js 21.x
- name: Use Node.js 22.x
uses: actions/setup-node@v1
with:
node-version: 21.x
node-version: 22.x
- name: Install npm packages using cache
uses: bahmutov/npm-install@v1
- name: Build OTP-RR
# Artifacts are shared between desktop and mobile tests (but not call-taker).
run: yarn build
env:
YAML_CONFIG: ../percy/har-mock-config.yml
YAML_CONFIG: ./percy/har-mock-config.yml
JS_CONFIG: ./percy/har-mock-config.js
- name: Take Percy Snapshots (Desktop + Mobile)
run: npx percy exec -- npx jest percy/percy.test.js --force-exit
Expand All @@ -39,21 +39,22 @@ jobs:
with:
# This allows us to work with the repository during the lint step
fetch-depth: 2
- name: Use Node.js 21.x
- name: Use Node.js 22.x
uses: actions/setup-node@v1
with:
node-version: 21.x
node-version: 22.x
- name: Install npm packages using cache
uses: bahmutov/npm-install@v1
- name: Download OTP2 config file
run: curl $PERCY_OTP2_CONFIG_URL --output /tmp/otp2config.yml
# Download into repo root, not /tmp (/tmp gets wiped at the beginning of the build process)
run: curl $PERCY_OTP2_CONFIG_URL --output ./otp2config.yml
env:
PERCY_OTP2_CONFIG_URL: ${{ secrets.PERCY_MOCK_OTP2_GEOCODER_CALLTAKER_CONFIG }}
- name: Build OTP-RR Calltaker
# Calltaker has a separate config file, so another build should be produced.
run: yarn build
env:
YAML_CONFIG: /tmp/otp2config.yml
YAML_CONFIG: ./otp2config.yml
JS_CONFIG: ./percy/har-mock-config-call-taker.js
- name: Take Percy Snapshots (Calltaker)
run: npx percy exec -- npx jest percy/percy.test.js --force-exit
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ dist
!test-config.yml
!har-mock-config.yml

# Ignore index.html at the root (it gets copied over during build)
index.html

# vscode extensions
.vscode
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
21
22
3 changes: 3 additions & 0 deletions __tests__/test-utils/mock-data/i18n-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function loadLocaleData(matchedLocale, customMessages) {
return {}
}
3 changes: 2 additions & 1 deletion a11y/a11y.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import routes from '../lib/util/webapp-routes'

import { mockServer } from './mock-server'

const OTP_RR_TEST_CONFIG_PATH = '../a11y/test-config.yml'
// Path relative to OTP-RR repo root.
const OTP_RR_TEST_CONFIG_PATH = './a11y/test-config.yml'

const MOCK_SERVER_PORT = 9999

Expand Down
228 changes: 0 additions & 228 deletions craco.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/config.js → example/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
BatchRoutingPanel,
BatchSearchScreen,
MetroItinerary
} from './index'
} from '../lib/index'

const ItineraryBody = MetroItinerary
const LegIcon = ClassicLegIcon
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion index.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@import url(lib/components/user/nav-login-button.css);
@import url(lib/components/viewers/viewers.css);


@import url(tmp/custom-styles.css);

/* Hide IE/Edge clear button in text input fields. */
input[type="text"]::-ms-clear {
Expand Down
3 changes: 0 additions & 3 deletions lib/actions/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* globals fetch */
import { push, replace } from 'connected-react-router'
import hash from 'object-hash'
import haversine from 'haversine'
Expand All @@ -15,8 +14,6 @@ import { MainPanelContent } from './ui-constants'
import v1Actions from './apiV1'
import v2Actions from './apiV2'

if (typeof fetch === 'undefined') require('isomorphic-fetch')

const { getRoutingParams, getUrlParams } = coreUtils.query

// Generic API actions
Expand Down
3 changes: 2 additions & 1 deletion lib/actions/apiV1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import qs from 'qs'
import maplibre from 'maplibre-gl'

import {
createQueryAction,
Expand All @@ -22,7 +23,7 @@ import { setViewedStop } from './ui'

// Import must be done like this as maplibregl is incompatible with jest
let maplibregl = null
if (typeof jest === 'undefined') maplibregl = require('maplibre-gl')
if (typeof jest === 'undefined') maplibregl = maplibre

const findTrip = (params) =>
createQueryAction(
Expand Down
4 changes: 2 additions & 2 deletions lib/actions/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import coreUtils from '@opentripplanner/core-utils'
import {
getConfigLocales,
getDefaultLocale,
getMatchingLocaleString,
loadLocaleData
getMatchingLocaleString
} from '../util/i18n'
import {
getItineraryView,
Expand All @@ -18,6 +17,7 @@ import {
ItineraryView
} from '../util/ui'
import { getModesForActiveAgencyFilter, getUiUrlParams } from '../util/state'
import { loadLocaleData } from '../util/i18n-loader'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you remember what the purpose of moving this into its own file was? Just curious

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is to isolate the parts that use the Vite-specific glob imports. This file is mocked for tests (tests continue to use Babel).


import {
clearActiveSearch,
Expand Down
Loading
Loading