Qrac

Results 43 comments of Qrac

アルファ版のTypeScript環境を最短で構築するコマンド。 ```sh $ npm init minista@latest -- --template ts $ npm i -D minista@next react@latest react-dom@latest @types/react@latest @types/react-dom@latest typescript@latest ```

v3アルファ版で動いたViteプラグイン。 - https://github.com/aleclarson/vite-tsconfig-paths - https://github.com/ElMassimo/vite-plugin-image-presets

MDXのcompileとrunをそのまま使っても上手くいかない。Automatic JSX Runtimeを解決するはずだが `_jsx is not a function` になってしまうので置換してimportしてみるが、それでも動かない。 ```ts const content = await compileMdx(childsStr, { outputFormat: "function-body", }) const replacedContent = content.toString().replace("arguments[0]", `await import("react/jsx-runtime")`) const contentReact = createElement(await runMdx(replacedContent,...

独自に処理した。MDXのcompile内容が変わった場合に動かなくなる可能性はある。 ```ts const content = await compileMdx(childsStr, config) let contentStr = content.value.toString() contentStr = contentStr.replace( /import {(.+?)} from "react\/jsx-runtime"/, 'const {$1} = await import("react/jsx-runtime")' ) contentStr = contentStr.replace(/\sas[(^const.*await import.*?)]/g, ":...

スプライトSVGの処理をViteに含ませる仕様に変更。

`3.0.0-alpha.4` リリース版を使った場合のみスプライトSVGが生成されていないとimportが解決されない。 ```sh Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/@minista-temp/__minista_plugin_icons.svg' imported from ... ```

srcから読み込んだCSSもバンドルに反映されてしまう。JSは反映されず紛らわしいので非推奨の書き方。 ```tsx import { Head } from "minista" export default function () { return ( index ) } ```

Vite v3で、CSSだけassetFileNamesがidではなくfilenameになってしまうバグがある~~ので `bundle.css` 用のファイル名変換を一時的に増やす必要あり~~。 - https://github.com/vitejs/vite/issues/9877 chunkInfoにも含まれていない。 ```js chunkInfo: { name: '../../packages/minista/dist/server/bundle.js', type: 'asset', source: '/* vite internal call, ignore */' } chunkInfo: { name: '../../packages/minista/dist/server/bundle.css', source: 'h1{color:red}\n', type: 'asset'...

型定義をViteに揃えた #93 ので仕様変更。 - #94

`create-minista` を書き直したので以下コマンドでv3アルファ版プロジェクトを作れるようになった。 ```sh $ npm create minista@next -- --tag v3 ``` インタラクティブUIをショートカットしたい場合はテンプレートをオプションで指定する。 ```sh $ npm create minista@next -- --tag v3 --template minimal-ts ```