Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh: Support vite v5 #87

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/__snapshots__/appconfig.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

exports[`app config > replaces process.env 1`] = `
"/*! third party licenses: js/vendor.LICENSE.txt */
window.my_timezone={}.TZ;
var e={};window.my_timezone=e.TZ;
"
`;
3 changes: 2 additions & 1 deletion lib/appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import type { UserConfig, UserConfigFn } from 'vite'
import type { PluginConfiguration as VitePluginInjectCSSOptions } from 'vite-plugin-css-injected-by-js/dist/esm/declarations/interface.js'
import type { BaseOptions, NodePolyfillsOptions } from './baseConfig.js'

import { mergeConfig } from 'vite'
Expand All @@ -15,6 +14,8 @@ import EmptyJSDirPlugin from './plugins/EmptyJSDir.js'
import replace from '@rollup/plugin-replace'
import injectCSSPlugin from 'vite-plugin-css-injected-by-js'

type VitePluginInjectCSSOptions = Parameters<typeof injectCSSPlugin>[0]

export const appName = process.env.npm_package_name
export const appVersion = process.env.npm_package_version
export const appNameSanitized = appName.replace(/[/\\]/, '-')
Expand Down
10 changes: 7 additions & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

export { createAppConfig, type AppOptions } from './appConfig.js'
export { createBaseConfig, type BaseOptions } from './baseConfig.js'
export { createLibConfig, type LibraryOptions } from './libConfig.js'
export type { BaseOptions } from './baseConfig.js'
export type { AppOptions } from './appConfig'
export type { LibraryOptions } from './libConfig.js'

export { createBaseConfig } from './baseConfig.js'
export { createAppConfig } from './appConfig.js'
export { createLibConfig } from './libConfig.js'

Check warning on line 13 in lib/index.ts

View check run for this annotation

Codecov / codecov/patch

lib/index.ts#L7-L13

Added lines #L7 - L13 were not covered by tests
4 changes: 2 additions & 2 deletions lib/libConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ export const createLibConfig = (entries: { [entryAlias: string]: string }, optio
peerDeps: true, // Peer dependencies should be by definition external
deps: true, // Runtime dependencies: Same as with peer dependencies
...options.nodeExternalsOptions,
});
}) as Plugin

// Order is important, run the plugin first
(node as Plugin).enforce = 'pre'
node.enforce = 'pre'
const plugins = [
// Make dependencies external
node,
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/EmptyJSDir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { Plugin } from 'vite'

import { existsSync, rmSync } from 'node:fs'
import * as path from 'node:path'

import type { Plugin } from 'vite'

/**
* Vite plugin to clear the `js/` directory before emitting files
*/
Expand Down
Loading
Loading