Skip to content
Draft
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
},
"packageManager": "[email protected]",
"dependencies": {
"@tanstack/react-start": "link:../playground/tanstack-quickstart/node_modules/@tanstack/react-start",
"lefthook": "^1.12.3",
"vite": "^7.0.5"
}
Expand Down
3 changes: 3 additions & 0 deletions packages/tanstack-start/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
package-lock.json
archived
5 changes: 5 additions & 0 deletions packages/tanstack-start/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
src
prepare.js
node_modules
scratchpad.js
package-lock.json
14 changes: 14 additions & 0 deletions packages/tanstack-start/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "always",
"printWidth": 80,
"endOfLine": "lf",
"jsxSingleQuote": true,
"proseWrap": "preserve",
"htmlWhitespaceSensitivity": "ignore"
}
105 changes: 105 additions & 0 deletions packages/tanstack-start/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Functional Source License, Version 1.1, ALv2 Future License

## Abbreviation

FSL-1.1-ALv2

## Notice

Copyright 2025 General Translation, Inc.

## Terms and Conditions

### Licensor ("We")

The party offering the Software under these Terms and Conditions.

### The Software

The "Software" is each version of the software that we make available under
these Terms and Conditions, as indicated by our inclusion of these Terms and
Conditions with the Software.

### License Grant

Subject to your compliance with this License Grant and the Patents,
Redistribution and Trademark clauses below, we hereby grant you the right to
use, copy, modify, create derivative works, publicly perform, publicly display
and redistribute the Software for any Permitted Purpose identified below.

### Permitted Purpose

A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
means making the Software available to others in a commercial product or
service that:

1. substitutes for the Software;

2. substitutes for any other product or service we offer using the Software
that exists as of the date we make the Software available; or

3. offers the same or substantially similar functionality as the Software.

Permitted Purposes specifically include using the Software:

1. for your internal use and access;

2. for non-commercial education;

3. for non-commercial research; and

4. in connection with professional services that you provide to a licensee
using the Software in accordance with these Terms and Conditions.

### Patents

To the extent your use for a Permitted Purpose would necessarily infringe our
patents, the license grant above includes a license under our patents. If you
make a claim against any party that the Software infringes or contributes to
the infringement of any patent, then your patent license to the Software ends
immediately.

### Redistribution

The Terms and Conditions apply to all copies, modifications and derivatives of
the Software.

If you redistribute any copies, modifications or derivatives of the Software,
you must include a copy of or a link to these Terms and Conditions and not
remove any copyright notices provided in or with the Software.

### Disclaimer

THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.

IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.

### Trademarks

Except for displaying the License Details and identifying us as the origin of
the Software, you have no right under these Terms and Conditions to use our
trademarks, trade names, service marks or product names.

## Grant of Future License

We hereby irrevocably grant you an additional license to use the Software under
the Apache License, Version 2.0 that is effective on the second anniversary of
the date we make the Software available. On or after that date, you may use the
Software under the Apache License, Version 2.0, in which case the following
will apply:

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
100 changes: 100 additions & 0 deletions packages/tanstack-start/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"name": "gt-tanstack-start",
"version": "0.0.0",
"description": "A Tanstack Start library for automatic internationalization.",
"main": "dist/index.server.js",
"peerDependencies": {
"react": ">=16.8.0 <20.0.0",
"react-dom": ">=16.8.0 <20.0.0",
"@tanstack/react-start": ">=1.0.0"
},
"files": [
"dist",
"CHANGELOG.md"
],
"dependencies": {
"@generaltranslation/react-core": "workspace:*",
"@generaltranslation/supported-locales": "workspace:*",
"generaltranslation": "workspace:*"
},
"scripts": {
"patch": "pnpm version patch",
"transpile": "tsc",
"build": "rollup -c",
"build:clean": "sh ../../scripts/clean.sh && pnpm run build",
"build:release": "pnpm run build:clean",
"release": "pnpm run build:clean && pnpm publish",
"release:alpha": "pnpm run build:clean && pnpm publish --tag alpha",
"release:beta": "pnpm run build:clean && pnpm publish --tag beta",
"release:latest": "pnpm run build:clean && pnpm publish --tag latest",
"lint": "eslint \"src/**/*.{js,ts,tsx}\" \"__tests__/**/*.{js,ts,tsx}\"",
"lint:fix": "eslint \"src/**/*.{js,ts,tsx}\" \"__tests__/**/*.{js,ts,tsx}\" --fix",
"test": "vitest run",
"test:watch": "vitest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/generaltranslation/gt.git"
},
"author": "General Translation, Inc.",
"license": "FSL-1.1-ALv2",
"bugs": {
"url": "https://github.com/generaltranslation/gt/issues"
},
"homepage": "https://generaltranslation.com/",
"devDependencies": {
"@babel/preset-react": "^7.26.3",
"@babel/preset-typescript": "^7.26.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^28.0.6",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.4",
"@types/node": "^22.13.5",
"@types/react": ">=18.0.0 <20.0.0",
"@types/react-dom": ">=18.0.0 <20.0.0",
"rollup": "^4.32.1",
"rollup-plugin-dts": "^6.2.3",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.2",
"rollup-preserve-directives": "^1.1.3",
"tslib": "^2.8.1",
"typescript": "^5.7.3"
},
"exports": {
".": {
"require": "./dist/index.cjs.min.cjs",
"types": "./dist/index.d.ts",
"import": "./dist/index.esm.min.mjs"
},
"./internal": {
"types": "./dist/internal.d.ts",
"require": "./dist/internal.cjs.min.cjs",
"import": "./dist/internal.esm.min.mjs"
},
"package.json": "./package.json"
},
"typesVersions": {
"*": {
"internal": [
"./dist/internal.d.ts"
]
}
},
"compilerOptions": {
"baseUrl": ".",
"paths": {
"gt-react/internal": [
"./dist/internal"
]
}
},
"keywords": [
"react",
"translation",
"internationalization",
"localization",
"i18n",
"l10n"
]
}
40 changes: 40 additions & 0 deletions packages/tanstack-start/rollup.base.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import postcss from 'rollup-plugin-postcss';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import { babel } from '@rollup/plugin-babel';
import preserveDirectives from 'rollup-preserve-directives';

export default {
plugins: [
peerDepsExternal(), // Exclude peer dependencies from the bundle
resolve({
// Locates and bundles dependencies in node_modules
browser: true,
preferBuiltins: false,
}),
commonjs(), // Converts CommonJS modules to ES6
babel({
// Transpiles the code using Babel
babelHelpers: 'bundled',
exclude: /node_modules/,
presets: ['@babel/preset-react', '@babel/preset-typescript'],
}),
typescript({
// Compiles TypeScript files
tsconfig: './tsconfig.json',
sourceMap: false,
outputToFilesystem: true, // supress warning about outputToFilesystem
}),
postcss(), // Process CSS files
preserveDirectives(), // Preserve directives in the output (i.e., "use client")
],
external: [
'react',
'react-dom',
'generaltranslation',
'@generaltranslation/supported-locales',
'@generaltranslation/react-core',
],
};
75 changes: 75 additions & 0 deletions packages/tanstack-start/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import baseConfig from './rollup.base.config.mjs';
import terser from '@rollup/plugin-terser';
import { dts } from 'rollup-plugin-dts';

export default [
/* ---------------------------------------- */
// Bundling for the library (index.ts)
{
input: './src/index.ts',
output: [
{
file: './dist/index.cjs.min.cjs',
format: 'cjs',
exports: 'auto', // 'auto' ensures compatibility with both default and named exports in CommonJS
sourcemap: true,
},
{
file: './dist/index.esm.min.mjs',
format: 'esm',
exports: 'named', // Named exports for ES modules
sourcemap: true,
},
],
plugins: [
...baseConfig.plugins,
terser(), // Minification
],
external: baseConfig.external,
},

// TypeScript declarations for the library (index.ts)
{
input: './src/index.ts',
output: {
file: './dist/index.d.ts',
format: 'esm',
},
plugins: [dts()],
},

/* ---------------------------------------- */
// Bundling for the internal library (internal.ts)
{
input: './src/internal.ts',
output: [
{
file: './dist/internal.cjs.min.cjs',
format: 'cjs',
exports: 'auto', // 'auto' ensures compatibility with both default and named exports in CommonJS
sourcemap: true,
},
{
file: './dist/internal.esm.min.mjs',
format: 'esm',
exports: 'named', // Named exports for ES modules
sourcemap: true,
},
],
plugins: [
...baseConfig.plugins,
terser(), // Minification
],
external: baseConfig.external,
},

// TypeScript declarations for the internal library (internal.ts)
{
input: './src/internal.ts',
output: {
file: './dist/internal.d.ts',
format: 'esm',
},
plugins: [dts()],
},
];
16 changes: 16 additions & 0 deletions packages/tanstack-start/src/compatability/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* This file is used for compatability issues to prevent errors when using import.meta.env with typescript.
* This avoids adding an extra dependency on vite/client
*/
interface ImportMetaEnv {
readonly VITE_GT_PROJECT_ID: string;
readonly VITE_GT_API_KEY: string;
readonly VITE_GT_DEV_API_KEY: string;
readonly REDWOOD_ENV_GT_PROJECT_ID: string; // uses vite
readonly REDWOOD_ENV_GT_API_KEY: string;
readonly REDWOOD_ENV_GT_DEV_API_KEY: string;
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}
1 change: 1 addition & 0 deletions packages/tanstack-start/src/errors-dir/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const PACKAGE_NAME = 'gt-tanstack-start';
Loading
Loading