optimize build tool chain.

This commit is contained in:
2025-07-03 16:43:25 +09:00
parent e37ac9aa4a
commit 5926c08da5
13 changed files with 660 additions and 766 deletions

1099
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,15 @@
{
"name": "kintone-plugin-docx",
"version": "1.0.1",
"version": "1.0.2",
"scripts": {
"prepare": "node scripts/prepare-private-key.js",
"gen": "run-s gen:*",
"gen:key": "node scripts/generate-private-key.js",
"start": "node scripts/npm-start.js",
"develop": "npm run build -- --watch",
"build": "npm run prepare && cross-env NODE_ENV=development rspack build",
"build:prod": "npm run prepare && cross-env NODE_ENV=production rspack build",
"prebuild": "npm run gen",
"prebuild:prod": "npm run gen",
"build": "cross-env NODE_ENV=development rspack build",
"build:prod": "cross-env NODE_ENV=production rspack build",
"dts-gen": "kintone-dts-gen",
"lint": "eslint src --ext .js,.jsx,.ts,.tsx",
"upload": "env-cmd --silent kintone-plugin-uploader dist/plugin.zip --watch --waiting-dialog-ms 3000"
@@ -16,7 +19,7 @@
"angular-expressions": "^1.4.3",
"clsx": "^2.1.1",
"dayjs": "^1.11.13",
"docxtemplater": "^3.65.0",
"docxtemplater": "^3.65.1",
"file-saver": "^2.0.5",
"moize": "^6.1.6",
"pizzip": "^3.2.0",
@@ -30,22 +33,21 @@
"@kintone/dts-gen": "^8.1.2",
"@kintone/plugin-uploader": "^9.1.5",
"@kintone/webpack-plugin-kintone-plugin": "^8.0.11",
"@rspack/cli": "^1.3.15",
"@rspack/core": "^1.3.15",
"@rspack/cli": "^1.4.2",
"@rspack/core": "^1.4.2",
"@shin-chan/kypes": "^0.0.7",
"@swc/helpers": "^0.5.17",
"@types/file-saver": "^2.0.7",
"@types/node": "^24.0.10",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
"cross-env": "^7.0.3",
"css-loader": "^7.1.2",
"env-cmd": "^10.1.0",
"eslint": "^9.29.0",
"eslint": "^9.30.1",
"eslint-plugin-react": "^7.37.5",
"globals": "^16.2.0",
"globals": "^16.3.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.5.3",
"style-loader": "^4.0.0",
"prettier": "^3.6.2",
"ts-node": "^10.9.2",
"typescript": "^5.8.3"
}
}

View File

@@ -1,18 +1,21 @@
{
"$schema": "https://raw.githubusercontent.com/kintone/js-sdk/%40kintone/plugin-manifest-validator%4010.2.0/packages/plugin-manifest-validator/manifest-schema.json",
"manifest_version": 1,
"version": "1.0.1",
"version": "1.0.2",
"type": "APP",
"desktop": {
"js": ["js/desktop.js"]
"js": ["js/desktop.js"],
"css": ["js/desktop.css"]
},
"mobile": {
"js": ["js/desktop.js"]
"js": ["js/desktop.js"],
"css": ["js/desktop.css"]
},
"icon": "image/icon.png",
"config": {
"html": "html/config.html",
"js": ["js/config.js"],
"css": ["js/config.css"],
"required_params": ["template"]
},
"name": {

View File

@@ -1,99 +0,0 @@
/* eslint-env node */
const path = require('path');
const KintonePlugin = require('@kintone/webpack-plugin-kintone-plugin');
const isProduction = process.env.NODE_ENV === 'production';
module.exports = {
mode: isProduction ? 'production' : 'development',
devtool: isProduction ? false : 'inline-cheap-module-source-map',
entry: { config: './src/config/index.tsx', desktop: './src/desktop/index.tsx' },
output: {
path: path.resolve(__dirname, 'plugin', 'js'),
filename: '[name].js',
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
module: {
rules: [
{
test: /\.(j|t)s$/,
exclude: [/[\\/]node_modules[\\/]/],
loader: 'builtin:swc-loader',
options: {
sourceMaps: !isProduction,
jsc: {
parser: {
syntax: 'typescript',
},
transform: {
react: {
runtime: 'automatic',
development: !isProduction,
},
},
externalHelpers: true,
},
env: {
targets: 'Chrome >= 48',
},
},
},
{
test: /\.(j|t)sx$/,
loader: 'builtin:swc-loader',
exclude: [/[\\/]node_modules[\\/]/],
options: {
sourceMaps: !isProduction,
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
transform: {
react: {
runtime: 'automatic',
development: !isProduction,
},
},
externalHelpers: true,
},
env: {
targets: 'Chrome >= 48', // browser compatibility
},
},
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
exclude: /\.module\.css$/,
},
{
test: /\.module\.css$/i,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
importLoaders: 1,
sourceMap: !isProduction,
modules: {
localIdentName: isProduction ? '[hash:base64]' : '[name]__[local]--[hash:base64:5]',
namedExport: false,
},
},
},
],
},
],
},
plugins: [
new KintonePlugin({
manifestJSONPath: './plugin/manifest.json',
privateKeyPath: './private.ppk',
pluginZipPath: './dist/plugin.zip',
}),
],
};

69
rspack.config.ts Normal file
View File

@@ -0,0 +1,69 @@
import { defineConfig } from '@rspack/cli';
import { rspack } from '@rspack/core';
import KintonePlugin from '@kintone/webpack-plugin-kintone-plugin';
const isDev = process.env.NODE_ENV === 'development';
// Target browsers, see: https://github.com/browserslist/browserslist
const targets = ['last 2 versions', '> 0.2%', 'not dead', 'Firefox ESR'];
export default defineConfig({
entry: { config: './src/config/index.tsx', desktop: './src/desktop/index.tsx' },
output: {
path: './plugin/js',
filename: '[name].js',
},
resolve: {
extensions: ['...', '.ts', '.tsx', '.jsx'],
},
devtool: isDev ? 'inline-cheap-module-source-map' : false,
module: {
rules: [
{
test: /\.(jsx?|tsx?)$/,
use: [
{
loader: 'builtin:swc-loader',
options: {
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
},
env: { targets },
},
},
],
},
],
parser: {
'css/auto': {
namedExports: false,
},
},
},
plugins: [
new KintonePlugin({
manifestJSONPath: './plugin/manifest.json',
privateKeyPath: './private.ppk',
pluginZipPath: './dist/plugin.zip',
}),
],
optimization: {
minimizer: [
new rspack.SwcJsMinimizerRspackPlugin(),
new rspack.LightningCssMinimizerRspackPlugin({
minimizerOptions: { targets },
}),
],
},
experiments: {
css: true,
},
performance: {
maxEntrypointSize: 1024000,
maxAssetSize: 1024000,
},
});

View File

@@ -7,14 +7,16 @@
background-color: rgba(0, 0, 0, 0.7);
z-index: 9999;
}
.spinner-container {
.spinnerContainer {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 10000;
}
.spinner-container .spinner {
.spinnerContainer .spinner {
font-size: 10px;
width: 1em;
height: 1em;
@@ -24,6 +26,7 @@
animation: mulShdSpin 1.1s infinite ease;
transform: translateZ(0);
}
@keyframes mulShdSpin {
0%,
100% {

View File

@@ -0,0 +1,7 @@
export const naturalCompare = (a: string, b: string): number => {
const locales = new Set<string>([...navigator.languages, 'en-US', 'ja-JP']);
return new Intl.Collator(Array.from(locales), {
sensitivity: 'variant',
numeric: true,
}).compare(a, b);
};

5
src/common/types.ts Normal file
View File

@@ -0,0 +1,5 @@
import { KintoneFormFieldProperty } from '@kintone/rest-api-client';
export type KintoneFormFieldProperties = {
[fieldCode: string]: KintoneFormFieldProperty.OneOf;
};

View File

@@ -1,10 +1,11 @@
import React from 'react';
import { KintoneRestAPIClient } from '@kintone/rest-api-client';
import { Properties as KintoneFormFieldProperties } from '@kintone/rest-api-client/lib/src/client/types';
import moize from 'moize';
import invariant from 'tiny-invariant';
import { PLUGIN_ID } from '../common/global';
import { naturalCompare } from '../common/stringUtils';
import { KintoneFormFieldProperties } from '../common/types';
import KintonePluginAlert from '../common/ui/KintonePluginAlert';
import KintonePluginButton from '../common/ui/KintonePluginButton';
import KintonePluginDesc from '../common/ui/KintonePluginDesc';
@@ -27,7 +28,9 @@ const Settings: React.FC = () => {
const appId = kintone.app.getId();
invariant(appId, 'The app ID is not available. Please ensure you are on a Kintone app page.');
const properties = React.use(cachedFormFieldsProperties(appId));
const fileFields = Object.values(properties).filter((property) => property.type === 'FILE');
const fileFields = Object.values(properties)
.filter((property) => property.type === 'FILE')
.sort((a, b) => naturalCompare(`${a.label} (${a.code})`, `${b.label} (${b.code})`));
const options: KintonePluginSelectOptionData[] = [
{ value: '', label: 'Select a File field', disabled: true }, // Default option
...fileFields.map((property) => ({

View File

@@ -1,7 +1,6 @@
import React from 'react';
import { KintoneFormFieldProperty, KintoneRestAPIClient } from '@kintone/rest-api-client';
import { Properties as KintoneFormFieldProperties } from '@kintone/rest-api-client/lib/src/client/types';
import { KintoneRecord } from '@shin-chan/kypes/types/page';
import dayjs from 'dayjs';
import Docxtemplater from 'docxtemplater';
@@ -11,6 +10,7 @@ import moize from 'moize';
import PizZip from 'pizzip';
import invariant from 'tiny-invariant';
import { DOCX_CONTENT_TYPE, LANGUAGE, PLUGIN_ID } from '../common/global';
import { KintoneFormFieldProperties } from '../common/types';
import KintonePluginAlert from '../common/ui/KintonePluginAlert';
import KintonePluginButton from '../common/ui/KintonePluginButton';

View File

@@ -7,11 +7,6 @@ declare module '*.module.css' {
const classes: CSSModuleClasses;
export default classes;
}
declare module '*.module.scss' {
const classes: CSSModuleClasses;
export default classes;
}
// CSS
declare module '*.css' {}
declare module '*.scss' {}

View File

@@ -1,73 +1,28 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
"lib": ["DOM", "ES2020"],
"jsx": "react-jsx",
"target": "ES2020",
"noEmit": true,
"skipLibCheck": true,
"useDefineForClassFields": true,
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "es2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"lib": ["dom", "es2020"], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./plugin", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* modules */
"module": "ESNext",
"resolveJsonModule": true,
"moduleResolution": "bundler",
"esModuleInterop": true,
"allowImportingTsExtensions": true,
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
/* type checking */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": [
"src/**/*",
"./node_modules/@kintone/dts-gen/kintone.d.ts"
]
"include": ["src/**/*", "./node_modules/@kintone/dts-gen/kintone.d.ts"],
"ts-node": {
"compilerOptions": {
"module": "CommonJS"
}
}
}