UNPKG

wuchale

Version:

Protobuf-like i18n from normal code

41 lines 1.62 kB
// $$ cd .. && npm run test import { defaultGenerateLoadID, defaultHeuristicFuncOnly } from '../adapters.js'; import { deepMergeObjects } from "../config.js"; import { Transformer } from "./transformer.js"; export { Transformer }; export { parseScript, scriptParseOptions, scriptParseOptionsWithComments } from './transformer.js'; const defaultArgs = { files: { include: 'src/**/*.{js,ts}', ignore: '**/*.d.ts' }, catalog: './src/locales/{locale}', pluralsFunc: 'plural', heuristic: defaultHeuristicFuncOnly, granularLoad: false, bundleLoad: false, generateLoadID: defaultGenerateLoadID, writeFiles: {}, importName: '_w_load_', runtime: { initInScope: ({ funcName }) => funcName != null, wrapInit: init => init, wrapExpr: expr => expr, } }; export const adapter = (args = defaultArgs) => { const { heuristic, pluralsFunc, runtime, ...rest } = deepMergeObjects(args, defaultArgs); return { transform: ({ content, filename, index, header }) => new Transformer(content, filename, index, heuristic, pluralsFunc, runtime, header.expr).transform(header.head), loaderExts: ['.js', '.ts'], defaultLoaders: async (dependencies) => { const available = ['server']; if (dependencies.has('vite')) { available.unshift('vite'); } return available; }, defaultLoaderPath: (loader) => { return new URL(`../../src/adapter-vanilla/loaders/${loader}.js`, import.meta.url).pathname; }, ...rest, }; }; //# sourceMappingURL=index.js.map