Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 14 additions & 9 deletions build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,29 @@ import tailwindcss from "tailwindcss";
// Load environment variables from .env file
dotenv.config();

const node_env = process.env.NODE_ENV || "production";

// List of environment variables to expose to the build
const env = {
const defineEnv = {
// Ref https://github.com/manzt/anywidget/issues/369#issuecomment-1792376003
"define.amd": "false",
"process.env.NODE_ENV": node_env,
"process.env.XSTATE_INSPECT": JSON.stringify(
process.env.XSTATE_INSPECT || "false",
),
};

esbuild.build({
entryPoints: ["./src/index.tsx"],
bundle: true,
minify: true,
target: ["es2022"],
outdir: "lonboard/static/",
bundle: true,
format: "esm",
// Ref https://github.com/manzt/anywidget/issues/369#issuecomment-1792376003
define: {
"define.amd": "false",
...env,
},
target: ["es2022"],
// Build sourcemaps when not in prod
sourcemap: node_env !== "production",
// Minify only in prod
minify: node_env === "production",
Comment on lines +30 to +33
Copy link
Member Author

Choose a reason for hiding this comment

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

ideally slightly easier browser debugging to have sourcemaps on and minify off in dev builds

define: defineEnv,
plugins: [
sassPlugin({
async transform(source) {
Expand All @@ -40,6 +44,7 @@ esbuild.build({
},
}),
],
platform: "browser",
loader: {
".worker.js": "text",
".worker.min.js": "text",
Expand Down
5 changes: 5 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import tseslint from "typescript-eslint";
export default [
{ files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"] },
{ languageOptions: { globals: globals.browser } },
// Esbuild build script should have access to Node globals
{
files: ["build.mjs"],
languageOptions: { globals: globals.node },
},
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
},
"scripts": {
"build": "node ./build.mjs",
"build:watch": "nodemon --watch src/ --exec \"npm run build\" --ext js,json,ts,tsx,css",
"build:dev": "NODE_ENV=development node ./build.mjs",
"build:watch": "nodemon --watch src/ --exec \"npm run build:dev\" --ext js,json,ts,tsx,css",
"prettier:check": "prettier './src/**/*.{ts,tsx,css}' --check",
"prettier": "prettier './src/**/*.{ts,tsx,css}' --write",
"lint": "eslint src",
Expand Down
27 changes: 15 additions & 12 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
"include": ["src/**/*"],
"exclude": ["node_modules"],
"compilerOptions": {
"module": "esnext",
"moduleResolution": "node",
"module": "ES2022",
"outDir": "./dist",
"allowJs": true,
"target": "ES2022",

"outDir": "./dist",
"rootDir": "src",
"declaration": true,
"declarationMap": true,
"sourceMap": true,

"strict": true,
"skipLibCheck": true,
"strictNullChecks": true,

"noEmit": false,
"noEmitOnError": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"skipLibCheck": true,
"strict": true,
"strictNullChecks": true,
// "lib": [
// "es2019.array", "es6", "dom"
// ],
"rootDir": "."
"esModuleInterop": true,

"jsx": "react-jsx",
"allowJs": true
}
}