@prosopo/config 3.3.7 → 3.3.9
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/.turbo/turbo-build$colon$cjs.log +7 -6
- package/.turbo/turbo-build$colon$tsc.log +4 -4
- package/.turbo/turbo-build.log +8 -7
- package/CHANGELOG.md +53 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/vite/index.cjs +2 -0
- package/dist/cjs/vite/vite-plugin-modify-exports-files.cjs +43 -0
- package/dist/cjs/vite/vite.frontend.config.cjs +11 -3
- package/dist/index.js +2 -1
- package/dist/vite/index.d.ts +1 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +2 -1
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/modifyExportsFiles.test.d.ts +2 -0
- package/dist/vite/modifyExportsFiles.test.d.ts.map +1 -0
- package/dist/vite/modifyExportsFiles.test.js +28 -0
- package/dist/vite/modifyExportsFiles.test.js.map +1 -0
- package/dist/vite/vite-plugin-modify-exports-files.d.ts +4 -0
- package/dist/vite/vite-plugin-modify-exports-files.d.ts.map +1 -0
- package/dist/vite/vite-plugin-modify-exports-files.js +42 -0
- package/dist/vite/vite-plugin-modify-exports-files.js.map +1 -0
- package/dist/vite/vite.frontend.config.d.ts.map +1 -1
- package/dist/vite/vite.frontend.config.js +11 -3
- package/dist/vite/vite.frontend.config.js.map +1 -1
- package/package.json +1 -1
- package/src/vite/index.ts +1 -0
- package/src/vite/modifyExportsFiles.test.ts +56 -0
- package/src/vite/vite-plugin-modify-exports-files.ts +64 -0
- package/src/vite/vite.frontend.config.ts +40 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -102,7 +102,15 @@ export default async function (
|
|
|
102
102
|
const { dependencies: deps, optionalPeerDependencies } =
|
|
103
103
|
await getDependencies(packageName, isProduction);
|
|
104
104
|
|
|
105
|
-
// Get rid of any dependencies we don't want to bundle
|
|
105
|
+
// Get rid of any dependencies we don't want to bundle.
|
|
106
|
+
// The two i18next entries are server-only: the fs backend reads locale JSON
|
|
107
|
+
// off disk and the middleware is Express request handling. Neither can run
|
|
108
|
+
// in a browser — `i18nBackend.ts` also imports `node:path`, which is already
|
|
109
|
+
// external — so they are pure weight in a frontend bundle. The other
|
|
110
|
+
// i18next-* packages (http-backend, browser-languagedetector,
|
|
111
|
+
// chained-backend, resources-to-backend) ARE used in the browser and must
|
|
112
|
+
// stay bundled; these filters are substring matches, so they catch only
|
|
113
|
+
// themselves.
|
|
106
114
|
const { external, internal } = filterDependencies(deps, [
|
|
107
115
|
"pm2",
|
|
108
116
|
"nodejs-polars",
|
|
@@ -110,14 +118,32 @@ export default async function (
|
|
|
110
118
|
"webpack",
|
|
111
119
|
"vite",
|
|
112
120
|
"i18next-fs-backend",
|
|
121
|
+
"i18next-http-middleware",
|
|
113
122
|
]);
|
|
114
123
|
|
|
124
|
+
// `external` only ever matches a specifier exactly, so listing a package by
|
|
125
|
+
// name does nothing for a subpath import of it. `i18next-fs-backend` has
|
|
126
|
+
// been on the exclusion list above for a long time, but `i18nBackend.ts`
|
|
127
|
+
// imports `i18next-fs-backend/cjs` (see i18next/i18next-fs-backend#57) —
|
|
128
|
+
// a different string — so it was bundled anyway, dragging its YAML, JSON5
|
|
129
|
+
// and JSONC parsers into the browser artifact.
|
|
130
|
+
//
|
|
131
|
+
// Listed literally rather than by matching `pkg/*` against the whole
|
|
132
|
+
// exclusion list: that broader rule also catches
|
|
133
|
+
// `vite-plugin-node-polyfills/shims/process` (the `vite` filter is a
|
|
134
|
+
// substring match, so it selects the plugin package too). That specifier is
|
|
135
|
+
// injected into the served and IIFE bundles as a bare import, and
|
|
136
|
+
// externalising it leaves the browser unable to resolve it — the widget dies
|
|
137
|
+
// on load with "Failed to resolve module specifier".
|
|
138
|
+
const serverOnlySubpaths = ["i18next-fs-backend/cjs"];
|
|
139
|
+
|
|
115
140
|
// Add the node builtins (path, fs, os, etc.) to the external list
|
|
116
141
|
const allExternal = [
|
|
117
142
|
...builtinModules,
|
|
118
143
|
...builtinModules.map((m) => `node:${m}`),
|
|
119
144
|
...external,
|
|
120
145
|
...optionalPeerDependencies,
|
|
146
|
+
...serverOnlySubpaths,
|
|
121
147
|
];
|
|
122
148
|
console.debug(
|
|
123
149
|
`Bundling. ${JSON.stringify(internal.slice(0, 10), null, 2)}... ${internal.length} deps`,
|
|
@@ -209,6 +235,19 @@ export default async function (
|
|
|
209
235
|
output: {
|
|
210
236
|
dir: path.resolve(dir, "dist/bundle"),
|
|
211
237
|
entryFileNames: `${bundleName}.bundle.js`,
|
|
238
|
+
// For a lib + es build, Vite downgrades `build.minify: true` to
|
|
239
|
+
// `{ compress, mangle, codegen: false }`, which leaves the output
|
|
240
|
+
// pretty-printed. Set it here to get whitespace removal too;
|
|
241
|
+
// output options win over the build-level default.
|
|
242
|
+
...(isProduction
|
|
243
|
+
? {
|
|
244
|
+
minify: {
|
|
245
|
+
compress: true,
|
|
246
|
+
mangle: true,
|
|
247
|
+
codegen: true,
|
|
248
|
+
},
|
|
249
|
+
}
|
|
250
|
+
: {}),
|
|
212
251
|
},
|
|
213
252
|
|
|
214
253
|
plugins: [
|