intl: use vite for building

This commit is contained in:
Abdullah Atta
2024-10-03 15:12:35 +05:00
committed by Abdullah Atta
parent bf7c7ebc82
commit cb50bccbeb
7 changed files with 1858 additions and 4194 deletions

View File

@@ -1,22 +0,0 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
module.exports = {
presets: ["@babel/env"],
plugins: ["macros"]
};

File diff suppressed because it is too large Load Diff

View File

@@ -2,27 +2,42 @@
"name": "@notesnook/intl",
"version": "1.0.0",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"license": "GPL-3.0-or-later",
"exports": {
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.mjs"
}
},
"repository": {
"type": "git",
"url": "git://github.com/streetwriters/notesnook.git"
},
"scripts": {
"extract": "lingui extract",
"compile": "lingui compile --typescript",
"build-locale": "yarn extract && yarn compile",
"build-locale": "npm run extract && npm run compile",
"clean": "rm -rf dist && rm -rf locales",
"build": "yarn build-locale && yarn rspack build && yarn tsc",
"start": "nodemon --watch ./src/strings.tsx --exec \"yarn rspack build && yarn tsc\""
"build": "npm run build-locale && npx vite build",
"watch": "nodemon --watch ./src/*.ts --exec \"npx vite build\""
},
"devDependencies": {
"@babel/core": "^7.24.9",
"@babel/preset-env": "^7.20.2",
"@lingui/cli": "^4.11.2",
"@lingui/macro": "^4.11.2",
"@lingui/cli": "^4.11.4",
"@lingui/macro": "^4.11.4 ",
"@lingui/swc-plugin": "^4.0.10",
"@types/react": "^18.2.39",
"babel-plugin-macros": "^3.1.0",
"react": "18.2.0",
"typescript": "5.5.3",
"@lingui/swc-plugin": "^4.0.7",
"@rspack/cli": "^0.6.2",
"@rspack/core": "^0.6.2"
"vite": "^5.4.8",
"vite-plugin-dts": "^4.2.3",
"vite-plugin-swc-transform": "^1.0.1"
},
"peerDependencies": {
"@lingui/macro": "*",

View File

@@ -1,81 +0,0 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const path = require("path");
/**
* @type {import('@rspack/cli').Configuration}
*/
module.exports = {
context: __dirname,
entry: {
main: "./index.ts"
},
output: {
library: {
type: "commonjs2"
},
filename: "index.js",
path: path.resolve(__dirname, "dist")
},
resolve: {
extensions: [".js", ".ts", ".tsx", ".jsx"]
},
optimization: {
minimize: false
},
externals: {
"@lingui/core": "@lingui/core",
"@lingui/react": "@lingui/react"
},
module: {
rules: [
{
test: /\.(jsx?|tsx?)$/,
exclude: /node_modules/,
use: [
{
loader: "builtin:swc-loader",
options: {
sourceMap: true,
jsc: {
parser: {
syntax: "typescript",
tsx: true
},
experimental: {
plugins: [
[
"@lingui/swc-plugin",
{
runtimeModules: {
i18n: ["./setup", "i18n"]
}
}
]
]
}
}
}
}
]
}
]
}
};

View File

@@ -17,8 +17,13 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export { messages as $en } from "./locales/$en.json";
export { messages as $de } from "./locales/$de.json";
export { messages as $fr } from "./locales/$fr.json";
export { strings } from "./src/strings";
export { setI18nGlobal } from "./src/setup";
import { messages as _$en } from "../locales/$en.json";
import { messages as _$de } from "../locales/$de.json";
import { messages as _$fr } from "../locales/$fr.json";
import type { Messages } from "@lingui/core";
export const $en = _$en as Messages;
export const $de = _$de as Messages;
export const $fr = _$fr as Messages;
export { strings } from "./strings";
export { setI18nGlobal } from "./setup";

View File

@@ -2,9 +2,8 @@
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "dist",
"jsx": "react-jsx",
"emitDeclarationOnly": true,
"declaration": true
},
"include": ["index.ts", "src", "locales"]
"include": ["src"]
}

View File

@@ -0,0 +1,65 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { resolve } from "path";
import { defineConfig } from "vite";
import swc from "vite-plugin-swc-transform";
import dts from "vite-plugin-dts";
export default defineConfig({
plugins: [
swc({
swcOptions: {
sourceMaps: true,
jsc: {
parser: {
syntax: "typescript",
tsx: true
},
experimental: {
plugins: [
[
"@lingui/swc-plugin",
{
runtimeModules: {
i18n: ["./setup", "i18n"]
}
}
]
]
}
}
}
}),
dts({
exclude: ["**/locales/*.json"],
rollupTypes: true
})
],
build: {
lib: {
entry: resolve(__dirname, "src/index.ts"),
formats: ["cjs", "es"],
fileName(format) {
return format === "cjs" ? "index.js" : "index.mjs";
}
},
outDir: resolve(__dirname, "dist")
}
});