@vocab/rollup-plugin 0.1.4-refine-watch-config-20251230003632 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -29,10 +29,10 @@ let fs_promises = require("fs/promises");
|
|
|
29
29
|
fs_promises = __toESM(fs_promises);
|
|
30
30
|
let path = require("path");
|
|
31
31
|
path = __toESM(path);
|
|
32
|
-
let
|
|
32
|
+
let _vocab_core = require("@vocab/core");
|
|
33
33
|
|
|
34
34
|
//#region src/index.ts
|
|
35
|
-
const isVocabFile = (id) =>
|
|
35
|
+
const isVocabFile = (id) => _vocab_core.compiledVocabFileFilter.test(id);
|
|
36
36
|
const promiseMap = async (items, fn) => Promise.all(items.map(fn));
|
|
37
37
|
const vocabTranslations = async ({ root }) => {
|
|
38
38
|
const { default: memoize } = await import("memoize");
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["compiledVocabFileFilter","fs"],"sources":["../src/index.ts"],"sourcesContent":["// Based off https://github.com/seek-oss/crackle/blob/ea226ae49853ca5531bb436334bc4e8d8ec1c49b/packages/core/src/plugins/rollup/vocab-translations.ts\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport { compiledVocabFileFilter } from '@vocab/core';\nimport type { Plugin, PluginContext } from 'rollup';\n\nconst isVocabFile = (id: string) => compiledVocabFileFilter.test(id);\n\nconst promiseMap = async <T, K>(\n items: T[],\n fn: (item: T) => Promise<K>,\n): Promise<K[]> => Promise.all(items.map(fn));\n\ntype PluginOptions = {\n /**\n * The root of the library that all paths are resolved relative to.\n * Typically this should be the root of your source code, e.g. `\"./src\"`,\n * _not_ the root of your library.\n */\n root: string;\n};\n\nexport const vocabTranslations = async ({\n root,\n}: PluginOptions): Promise<Plugin> => {\n const { default: memoize } = await import('memoize');\n\n // Because this is called for every generated Vocab translation file, we don't want to emit assets\n // multiple times. The function is memoized so that it only emits assets once per `vocab` directory,\n // because the translation file can be imported from multiple places.\n const handleVocabTranslations = memoize(async function (\n this: PluginContext,\n vocabDir: string,\n ) {\n await promiseMap(await fs.readdir(vocabDir), async (name) => {\n if (name.endsWith('translations.json')) {\n const json = await fs.readFile(path.join(vocabDir, name), 'utf-8');\n const originalFileName = path.join(vocabDir, name);\n\n this.emitFile({\n type: 'asset',\n fileName: path.relative(root, originalFileName),\n source: json,\n });\n }\n });\n\n // return value is important for memoize\n return null;\n });\n\n return {\n name: 'vocab:translations-files',\n\n resolveId: {\n order: 'pre',\n async handler(id, importer, options) {\n const resolved = await this.resolve(id, importer, {\n skipSelf: true,\n ...options,\n });\n\n if (resolved && isVocabFile(resolved.id)) {\n const vocabDir = path.dirname(resolved.id);\n await handleVocabTranslations.call(this, vocabDir);\n }\n },\n },\n async renderChunk(_code, chunk, outputOptions) {\n if (!outputOptions.preserveModules) {\n this.warn(\n '@vocab/rollup-plugin can only bundle translations.json files if `preserveModules` is enabled',\n );\n }\n const outDir = outputOptions.dir;\n if (!outDir) {\n // Should never happen as rollup validates that `dir` is provided if `preserveModules` is\n // true\n this.error(\n 'Output directory not specified. Please set the `dir` option in your Rollup configuration.',\n );\n }\n\n for (const moduleId of chunk.moduleIds) {\n if (isVocabFile(moduleId)) {\n const vocabDir = path.dirname(moduleId);\n if (outDir) {\n await handleVocabTranslations.call(this, vocabDir);\n }\n }\n }\n },\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,eAAe,OAAeA,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["compiledVocabFileFilter","fs"],"sources":["../src/index.ts"],"sourcesContent":["// Based off https://github.com/seek-oss/crackle/blob/ea226ae49853ca5531bb436334bc4e8d8ec1c49b/packages/core/src/plugins/rollup/vocab-translations.ts\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport { compiledVocabFileFilter } from '@vocab/core';\nimport type { Plugin, PluginContext } from 'rollup';\n\nconst isVocabFile = (id: string) => compiledVocabFileFilter.test(id);\n\nconst promiseMap = async <T, K>(\n items: T[],\n fn: (item: T) => Promise<K>,\n): Promise<K[]> => Promise.all(items.map(fn));\n\ntype PluginOptions = {\n /**\n * The root of the library that all paths are resolved relative to.\n * Typically this should be the root of your source code, e.g. `\"./src\"`,\n * _not_ the root of your library.\n */\n root: string;\n};\n\nexport const vocabTranslations = async ({\n root,\n}: PluginOptions): Promise<Plugin> => {\n const { default: memoize } = await import('memoize');\n\n // Because this is called for every generated Vocab translation file, we don't want to emit assets\n // multiple times. The function is memoized so that it only emits assets once per `vocab` directory,\n // because the translation file can be imported from multiple places.\n const handleVocabTranslations = memoize(async function (\n this: PluginContext,\n vocabDir: string,\n ) {\n await promiseMap(await fs.readdir(vocabDir), async (name) => {\n if (name.endsWith('translations.json')) {\n const json = await fs.readFile(path.join(vocabDir, name), 'utf-8');\n const originalFileName = path.join(vocabDir, name);\n\n this.emitFile({\n type: 'asset',\n fileName: path.relative(root, originalFileName),\n source: json,\n });\n }\n });\n\n // return value is important for memoize\n return null;\n });\n\n return {\n name: 'vocab:translations-files',\n\n resolveId: {\n order: 'pre',\n async handler(id, importer, options) {\n const resolved = await this.resolve(id, importer, {\n skipSelf: true,\n ...options,\n });\n\n if (resolved && isVocabFile(resolved.id)) {\n const vocabDir = path.dirname(resolved.id);\n await handleVocabTranslations.call(this, vocabDir);\n }\n },\n },\n async renderChunk(_code, chunk, outputOptions) {\n if (!outputOptions.preserveModules) {\n this.warn(\n '@vocab/rollup-plugin can only bundle translations.json files if `preserveModules` is enabled',\n );\n }\n const outDir = outputOptions.dir;\n if (!outDir) {\n // Should never happen as rollup validates that `dir` is provided if `preserveModules` is\n // true\n this.error(\n 'Output directory not specified. Please set the `dir` option in your Rollup configuration.',\n );\n }\n\n for (const moduleId of chunk.moduleIds) {\n if (isVocabFile(moduleId)) {\n const vocabDir = path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AAW,aAAK,QAAQ,SAAS;AACvC,QAAI,OACF,OAAM,wBAAwB,KAAK,MAAM,SAAS;;;EAK3D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vocab/rollup-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/seek-oss/vocab.git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"memoize": "^10.1.0",
|
|
26
|
-
"@vocab/core": "^1.7.
|
|
26
|
+
"@vocab/core": "^1.7.5"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"rolldown": ">=1.0.0-beta.47",
|