Compare commits

...

16 Commits

Author SHA1 Message Date
GitHub Actions 03c8ab4d6f chore(release): v0.10.3 2023-11-28 18:18:59 +00:00
Aaron df13b9705c fix(auto-imports): Don't add imports to node_module dependencies (#247) 2023-11-28 12:15:05 -06:00
Aaron 762ba0080d chore(deps): Upgrade to typescript 5.3 (#245) 2023-11-27 10:03:03 -06:00
Aaron Klinker 317b1b6dcc docs: Fix typo 2023-11-27 09:57:09 -06:00
Aaron 93175a6477 chore: Use defu for merging some config objects (#243) 2023-11-26 12:23:10 -06:00
Aaron 60d6707b11 chore: Use normalize-path instead of vite.normalizePath (#244) 2023-11-26 11:36:42 -06:00
Aaron Klinker 97cbda3dab ci: only print response headers from docs webhook 2023-11-25 14:57:04 -06:00
Aaron Klinker 1611c1dba6 ci: Publish docs on push to main 2023-11-25 14:51:30 -06:00
Aaron Klinker b59252284a Print verbose webhook 2023-11-25 14:48:05 -06:00
Aaron Klinker 742b99657a chore: Trigger docs upgrade via webhook 2023-11-25 14:45:41 -06:00
Aaron Klinker e2997a43e0 Fix docker push command 2023-11-24 14:18:27 -06:00
Aaron Klinker 21dead60fd Self-host docs 2023-11-24 14:16:18 -06:00
GitHub Actions 3d1bc0a12c chore(release): v0.10.2 2023-11-20 19:52:55 +00:00
Aaron Klinker 4b24bee1fb Update demo app logs 2023-11-20 13:47:31 -06:00
Aaron Klinker 82ed821eb5 fix: Apply mode option to build steps correctly 2023-11-20 13:47:18 -06:00
Aaron 60625280c2 chore: Upgrade templates to v0.10 (#239) 2023-11-16 16:50:30 -06:00
21 changed files with 200 additions and 71 deletions
+27
View File
@@ -0,0 +1,27 @@
name: Publish Docs
on:
push:
branches:
- main
workflow_dispatch:
inputs:
tag:
description: Docker Image Tag
required: true
default: latest
jobs:
publish:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- uses: docker/login-action@v3
with:
registry: https://${{ secrets.DOCKER_REGISTRY_HOSTNAME }}
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
- run: pnpm docs:build
- run: docker build docs/.vitepress -t ${{ secrets.DOCKER_REGISTRY_HOSTNAME }}/wxt/docs:${{ github.event.inputs.tag || 'latest' }}
- run: docker push ${{ secrets.DOCKER_REGISTRY_HOSTNAME }}/wxt/docs:${{ github.event.inputs.tag || 'latest' }}
- run: curl -X POST -i ${{ secrets.UPDATE_DOCS_WEBHOOK }}
+35
View File
@@ -1,5 +1,40 @@
# Changelog
## v0.10.3
[compare changes](https://github.com/wxt-dev/wxt/compare/v0.10.2...v0.10.3)
### 🩹 Fixes
- **auto-imports:** Don't add imports to `node_module` dependencies ([#247](https://github.com/wxt-dev/wxt/pull/247))
### 📖 Documentation
- Fix typo ([317b1b6](https://github.com/wxt-dev/wxt/commit/317b1b6))
### 🏡 Chore
- Trigger docs upgrade via webhook ([742b996](https://github.com/wxt-dev/wxt/commit/742b996))
- Use `normalize-path` instead of `vite.normalizePath` ([#244](https://github.com/wxt-dev/wxt/pull/244))
- Use `defu` for merging some config objects ([#243](https://github.com/wxt-dev/wxt/pull/243))
### 🤖 CI
- Publish docs on push to main ([1611c1d](https://github.com/wxt-dev/wxt/commit/1611c1d))
- Only print response headers from docs webhook ([97cbda3](https://github.com/wxt-dev/wxt/commit/97cbda3))
## v0.10.2
[compare changes](https://github.com/wxt-dev/wxt/compare/v0.10.1...v0.10.2)
### 🩹 Fixes
- Apply `mode` option to build steps correctly ([82ed821](https://github.com/wxt-dev/wxt/commit/82ed821))
### 🏡 Chore
- Upgrade templates to v0.10 ([#239](https://github.com/wxt-dev/wxt/pull/239))
## v0.10.1
[compare changes](https://github.com/wxt-dev/wxt/compare/v0.10.0...v0.10.1)
+1 -1
View File
@@ -86,7 +86,7 @@ Note that templates are hardcoded to a specific version of `wxt` from NPM, they
```diff
"devDependencies": {
"typescript": "^5.1.6",
"typescript": "^5.3.2",
"vite-plugin-solid": "^2.7.0",
- "wxt": "^0.8.0"
+ "wxt": "../.."
+5 -1
View File
@@ -23,7 +23,11 @@ export default defineBackground(() => {
browser.i18n.getMessage('bye', ['Aaron']);
browser.i18n.getMessage('@@extension_id');
console.log('WXT MODE:', import.meta.env.MODE);
console.log('WXT MODE:', {
MODE: import.meta.env.MODE,
DEV: import.meta.env.DEV,
PROD: import.meta.env.PROD,
});
storage.setItem('session:startTime', Date.now());
});
+5 -1
View File
@@ -6,7 +6,11 @@ export default defineContentScript({
console.log(browser.runtime.id);
logId();
console.log('WXT MODE:', import.meta.env.MODE);
console.log('WXT MODE:', {
MODE: import.meta.env.MODE,
DEV: import.meta.env.DEV,
PROD: import.meta.env.PROD,
});
const n = (Math.random() * 100).toFixed(1);
ctx.setInterval(() => {
+5 -1
View File
@@ -4,4 +4,8 @@ console.log(browser.runtime.id);
logId();
console.log(2);
console.log('WXT MODE:', import.meta.env.MODE);
console.log('WXT MODE:', {
MODE: import.meta.env.MODE,
DEV: import.meta.env.DEV,
PROD: import.meta.env.PROD,
});
+2
View File
@@ -0,0 +1,2 @@
FROM lipanski/docker-static-website:latest
COPY dist .
+6 -3
View File
@@ -1,7 +1,7 @@
{
"name": "wxt",
"type": "module",
"version": "0.10.1",
"version": "0.10.3",
"description": "Next gen framework for developing web extensions",
"engines": {
"node": ">=18",
@@ -88,6 +88,7 @@
"c12": "^1.5.1",
"cac": "^6.7.14",
"consola": "^3.2.3",
"defu": "^6.1.3",
"esbuild": "^0.19.5",
"fast-glob": "^3.3.1",
"filesize": "^10.0.8",
@@ -100,6 +101,7 @@
"json5": "^2.2.3",
"linkedom": "^0.16.1",
"minimatch": "^9.0.3",
"normalize-path": "^3.0.0",
"ora": "^7.0.1",
"picocolors": "^1.0.0",
"prompts": "^2.4.2",
@@ -116,6 +118,7 @@
"@types/fs-extra": "^11.0.3",
"@types/lodash.merge": "^4.6.8",
"@types/node": "^20.8.10",
"@types/normalize-path": "^3.0.2",
"@types/prompts": "^2.4.7",
"@vitest/coverage-v8": "^0.34.6",
"execa": "^8.0.1",
@@ -128,10 +131,10 @@
"simple-git-hooks": "^2.9.0",
"tsup": "^7.2.0",
"tsx": "^3.12.7",
"typedoc": "^0.25.3",
"typedoc": "^0.25.4",
"typedoc-plugin-markdown": "4.0.0-next.23",
"typedoc-vitepress-theme": "1.0.0-next.3",
"typescript": "^5.2.2",
"typescript": "^5.3.2",
"vitepress": "1.0.0-rc.24",
"vitest": "^0.34.6",
"vitest-mock-extended": "^1.3.1",
+50 -32
View File
@@ -32,6 +32,9 @@ importers:
consola:
specifier: ^3.2.3
version: 3.2.3
defu:
specifier: ^6.1.3
version: 6.1.3
esbuild:
specifier: ^0.19.5
version: 0.19.5
@@ -68,6 +71,9 @@ importers:
minimatch:
specifier: ^9.0.3
version: 9.0.3
normalize-path:
specifier: ^3.0.0
version: 3.0.0
ora:
specifier: ^7.0.1
version: 7.0.1
@@ -111,6 +117,9 @@ importers:
'@types/node':
specifier: ^20.8.10
version: 20.8.10
'@types/normalize-path':
specifier: ^3.0.2
version: 3.0.2
'@types/prompts':
specifier: ^2.4.7
version: 2.4.7
@@ -143,34 +152,34 @@ importers:
version: 2.9.0
tsup:
specifier: ^7.2.0
version: 7.2.0(typescript@5.2.2)
version: 7.2.0(typescript@5.3.2)
tsx:
specifier: ^3.12.7
version: 3.14.0
typedoc:
specifier: ^0.25.3
version: 0.25.3(typescript@5.2.2)
specifier: ^0.25.4
version: 0.25.4(typescript@5.3.2)
typedoc-plugin-markdown:
specifier: 4.0.0-next.23
version: 4.0.0-next.23(typedoc@0.25.3)
version: 4.0.0-next.23(typedoc@0.25.4)
typedoc-vitepress-theme:
specifier: 1.0.0-next.3
version: 1.0.0-next.3(typedoc-plugin-markdown@4.0.0-next.23)
typescript:
specifier: ^5.2.2
version: 5.2.2
specifier: ^5.3.2
version: 5.3.2
vitepress:
specifier: 1.0.0-rc.24
version: 1.0.0-rc.24(@types/node@20.8.10)(typescript@5.2.2)
version: 1.0.0-rc.24(@types/node@20.8.10)(typescript@5.3.2)
vitest:
specifier: ^0.34.6
version: 0.34.6(happy-dom@12.10.3)(sass@1.69.5)
vitest-mock-extended:
specifier: ^1.3.1
version: 1.3.1(typescript@5.2.2)(vitest@0.34.6)
version: 1.3.1(typescript@5.3.2)(vitest@0.34.6)
vue:
specifier: ^3.3.7
version: 3.3.7(typescript@5.2.2)
version: 3.3.7(typescript@5.3.2)
demo:
dependencies:
@@ -1178,6 +1187,10 @@ packages:
dependencies:
undici-types: 5.26.5
/@types/normalize-path@3.0.2:
resolution: {integrity: sha512-DO++toKYPaFn0Z8hQ7Tx+3iT9t77IJo/nDiqTXilgEP+kPNIYdpS9kh3fXuc53ugqwp9pxC1PVjCpV1tQDyqMA==}
dev: true
/@types/prompts@2.4.7:
resolution: {integrity: sha512-5zTamE+QQM4nR6Ab3yHK+ovWuhLJXaa2ZLt3mT1en8U3ubWtjVT1vXDaVFC2+cL89uVn7Y+gIq5B3IcVvBl5xQ==}
dependencies:
@@ -1222,7 +1235,7 @@ packages:
vue: ^3.2.25
dependencies:
vite: 4.5.0(@types/node@20.8.10)(sass@1.69.5)
vue: 3.3.7(typescript@5.2.2)
vue: 3.3.7(typescript@5.3.2)
dev: true
/@vitest/coverage-v8@0.34.6(vitest@0.34.6):
@@ -1359,7 +1372,7 @@ packages:
dependencies:
'@vue/compiler-ssr': 3.3.7
'@vue/shared': 3.3.7
vue: 3.3.7(typescript@5.2.2)
vue: 3.3.7(typescript@5.3.2)
dev: true
/@vue/shared@3.3.7:
@@ -2558,6 +2571,7 @@ packages:
/glob@6.0.4:
resolution: {integrity: sha512-MKZeRNyYZAVVVG1oZeLaWie1uweH40m9AZwIwxyPbTSX4hHrVYSzLg0Ro5Z5R7XKkIX+Cc6oD1rqeDJnwsB8/A==}
requiresBuild: true
dependencies:
inflight: 1.0.6
inherits: 2.0.4
@@ -3498,6 +3512,7 @@ packages:
/mkdirp@0.5.6:
resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==}
hasBin: true
requiresBuild: true
dependencies:
minimist: 1.2.8
dev: false
@@ -3565,6 +3580,7 @@ packages:
/nan@2.17.0:
resolution: {integrity: sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==}
requiresBuild: true
dev: false
optional: true
@@ -3580,6 +3596,7 @@ packages:
/ncp@2.0.0:
resolution: {integrity: sha512-zIdGUrPRFTUELUvr3Gmc7KZ2Sw/h1PiVM0Af/oHB6zgnV1ikqSfRk+TOufi79aHYCW3NiOXmr1BP5nWbzojLaA==}
hasBin: true
requiresBuild: true
dev: false
optional: true
@@ -4129,6 +4146,7 @@ packages:
/rimraf@2.4.5:
resolution: {integrity: sha512-J5xnxTyqaiw06JjMftq7L9ouA448dw/E7dKghkP9WpKNuwmARNNg+Gk8/u5ryb9N/Yo2+z3MCwuqFK/+qPOPfQ==}
hasBin: true
requiresBuild: true
dependencies:
glob: 6.0.4
dev: false
@@ -4634,12 +4652,12 @@ packages:
hasBin: true
dev: true
/ts-essentials@9.3.2(typescript@5.2.2):
/ts-essentials@9.3.2(typescript@5.3.2):
resolution: {integrity: sha512-JxKJzuWqH1MmH4ZFHtJzGEhkfN3QvVR3C3w+4BIoWeoY68UVVoA2Np/Bca9z0IPSErVCWhv439aT0We4Dks8kQ==}
peerDependencies:
typescript: '>=4.1.0'
dependencies:
typescript: 5.2.2
typescript: 5.3.2
dev: true
/ts-interface-checker@0.1.13:
@@ -4650,7 +4668,7 @@ packages:
resolution: {integrity: sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA==}
dev: false
/tsup@7.2.0(typescript@5.2.2):
/tsup@7.2.0(typescript@5.3.2):
resolution: {integrity: sha512-vDHlczXbgUvY3rWvqFEbSqmC1L7woozbzngMqTtL2PGBODTtWlRwGDDawhvWzr5c1QjKe4OAKqJGfE1xeXUvtQ==}
engines: {node: '>=16.14'}
hasBin: true
@@ -4680,7 +4698,7 @@ packages:
source-map: 0.8.0-beta.0
sucrase: 3.32.0
tree-kill: 1.2.2
typescript: 5.2.2
typescript: 5.3.2
transitivePeerDependencies:
- supports-color
- ts-node
@@ -4733,12 +4751,12 @@ packages:
resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==}
dev: false
/typedoc-plugin-markdown@4.0.0-next.23(typedoc@0.25.3):
/typedoc-plugin-markdown@4.0.0-next.23(typedoc@0.25.4):
resolution: {integrity: sha512-bKD0LnrQxUTbuDRiJfCWYLlzyERuskWldJ5eWKKuNY38xBOyBhSN8P+vD5KxlJoAifTOm76MK58sNrl4wgOoWg==}
peerDependencies:
typedoc: '>=0.25.0'
dependencies:
typedoc: 0.25.3(typescript@5.2.2)
typedoc: 0.25.4(typescript@5.3.2)
dev: true
/typedoc-vitepress-theme@1.0.0-next.3(typedoc-plugin-markdown@4.0.0-next.23):
@@ -4746,25 +4764,25 @@ packages:
peerDependencies:
typedoc-plugin-markdown: '>=4.0.0-next.19'
dependencies:
typedoc-plugin-markdown: 4.0.0-next.23(typedoc@0.25.3)
typedoc-plugin-markdown: 4.0.0-next.23(typedoc@0.25.4)
dev: true
/typedoc@0.25.3(typescript@5.2.2):
resolution: {integrity: sha512-Ow8Bo7uY1Lwy7GTmphRIMEo6IOZ+yYUyrc8n5KXIZg1svpqhZSWgni2ZrDhe+wLosFS8yswowUzljTAV/3jmWw==}
/typedoc@0.25.4(typescript@5.3.2):
resolution: {integrity: sha512-Du9ImmpBCw54bX275yJrxPVnjdIyJO/84co0/L9mwe0R3G4FSR6rQ09AlXVRvZEGMUg09+z/usc8mgygQ1aidA==}
engines: {node: '>= 16'}
hasBin: true
peerDependencies:
typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x
typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x
dependencies:
lunr: 2.3.9
marked: 4.3.0
minimatch: 9.0.3
shiki: 0.14.5
typescript: 5.2.2
typescript: 5.3.2
dev: true
/typescript@5.2.2:
resolution: {integrity: sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==}
/typescript@5.3.2:
resolution: {integrity: sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==}
engines: {node: '>=14.17'}
hasBin: true
dev: true
@@ -5014,7 +5032,7 @@ packages:
optionalDependencies:
fsevents: 2.3.3
/vitepress@1.0.0-rc.24(@types/node@20.8.10)(typescript@5.2.2):
/vitepress@1.0.0-rc.24(@types/node@20.8.10)(typescript@5.3.2):
resolution: {integrity: sha512-RpnL8cnOGwiRlBbrYQUm9sYkJbtyOt/wYXk2diTcokY4yvks/5lq9LuSt+MURWB6ZqwpSNHvTmxgaSfLoG0/OA==}
hasBin: true
peerDependencies:
@@ -5038,7 +5056,7 @@ packages:
minisearch: 6.2.0
shiki: 0.14.5
vite: 4.5.0(@types/node@20.8.10)(sass@1.69.5)
vue: 3.3.7(typescript@5.2.2)
vue: 3.3.7(typescript@5.3.2)
transitivePeerDependencies:
- '@algolia/client-search'
- '@types/node'
@@ -5067,14 +5085,14 @@ packages:
- universal-cookie
dev: true
/vitest-mock-extended@1.3.1(typescript@5.2.2)(vitest@0.34.6):
/vitest-mock-extended@1.3.1(typescript@5.3.2)(vitest@0.34.6):
resolution: {integrity: sha512-OpghYjh4BDuQ/Mzs3lFMQ1QRk9D8/2O9T47MLUA5eLn7K4RWIy+MfIivYOWEyxjTENjsBnzgMihDjyNalN/K0Q==}
peerDependencies:
typescript: 3.x || 4.x || 5.x
vitest: '>=0.31.1'
dependencies:
ts-essentials: 9.3.2(typescript@5.2.2)
typescript: 5.2.2
ts-essentials: 9.3.2(typescript@5.3.2)
typescript: 5.3.2
vitest: 0.34.6(happy-dom@12.10.3)(sass@1.69.5)
dev: true
@@ -5163,10 +5181,10 @@ packages:
'@vue/composition-api':
optional: true
dependencies:
vue: 3.3.7(typescript@5.2.2)
vue: 3.3.7(typescript@5.3.2)
dev: true
/vue@3.3.7(typescript@5.2.2):
/vue@3.3.7(typescript@5.3.2):
resolution: {integrity: sha512-YEMDia1ZTv1TeBbnu6VybatmSteGOS3A3YgfINOfraCbf85wdKHzscD6HSS/vB4GAtI7sa1XPX7HcQaJ1l24zA==}
peerDependencies:
typescript: '*'
@@ -5179,7 +5197,7 @@ packages:
'@vue/runtime-dom': 3.3.7
'@vue/server-renderer': 3.3.7(vue@3.3.7)
'@vue/shared': 3.3.7
typescript: 5.2.2
typescript: 5.3.2
dev: true
/watchpack@2.4.0:
+24
View File
@@ -0,0 +1,24 @@
import { describe, expect, it } from 'vitest';
import { normalizePath } from '../paths';
describe('Path Utils', () => {
describe('normalizePath', () => {
it.each([
// Relative paths
['../test.sh', '../test.sh'],
['..\\test.sh', '../test.sh'],
['test.png', 'test.png'],
// Absolute paths
['C:\\\\path\\to\\file', 'C:/path/to/file'],
['/path/to/file', '/path/to/file'],
// Strip trailing slash
['C:\\\\path\\to\\folder\\', 'C:/path/to/folder'],
['/path/to/folder/', '/path/to/folder'],
// Dedupe slashes
['path\\\\\\file', 'path/file'],
['path//file', 'path/file'],
])('should normalize "%s" to "%s"', (input, expected) => {
expect(normalizePath(input)).toBe(expected);
});
});
});
@@ -71,6 +71,7 @@ async function buildSingleEntrypoint(
}
const libMode: vite.UserConfig = {
mode: config.mode,
plugins,
build: {
lib: {
@@ -128,6 +129,7 @@ async function buildMultipleEntrypoints(
config: InternalConfig,
): Promise<BuildStepOutput> {
const multiPage: vite.UserConfig = {
mode: config.mode,
plugins: [wxtPlugins.multipageMove(entrypoints, config)],
build: {
rollupOptions: {
@@ -14,6 +14,7 @@ import * as vite from 'vite';
import { createFsCache } from '~/core/utils/cache';
import consola, { LogLevels } from 'consola';
import * as plugins from '~/core/vite-plugins';
import defu from 'defu';
/**
* Given an inline config, discover the config file if necessary, merge the results, resolve any
@@ -172,13 +173,13 @@ function mergeInlineConfig(
const inline = await inlineConfig.vite?.(env);
return vite.mergeConfig(user ?? {}, inline ?? {});
};
const runner: InlineConfig['runner'] = vite.mergeConfig(
userConfig.runner ?? {},
const runner: InlineConfig['runner'] = defu(
inlineConfig.runner ?? {},
userConfig.runner ?? {},
);
const zip: InlineConfig['zip'] = vite.mergeConfig(
userConfig.zip ?? {},
const zip: InlineConfig['zip'] = defu(
inlineConfig.zip ?? {},
userConfig.zip ?? {},
);
return {
+3 -3
View File
@@ -23,7 +23,7 @@ import { getPackageJson } from './package';
import { normalizePath } from './paths';
import { writeFileIfDifferent } from './fs';
import { produce } from 'immer';
import * as vite from 'vite';
import defu from 'defu';
/**
* Writes the manifest to the output directory and the build output.
@@ -78,9 +78,9 @@ export async function generateMainfest(
};
const userManifest = config.manifest;
const manifest = vite.mergeConfig(
baseManifest,
const manifest = defu(
userManifest,
baseManifest,
) as Manifest.WebExtensionManifest;
addEntrypoints(manifest, entrypoints, buildOutput, config);
+4 -4
View File
@@ -1,19 +1,19 @@
import nodePath from 'node:path';
import * as vite from 'vite';
import systemPath from 'node:path';
import normalize from 'normalize-path';
/**
* Converts system paths to normalized bundler path. On windows and unix, this returns paths with /
* instead of \.
*/
export function normalizePath(path: string): string {
return vite.normalizePath(path);
return normalize(path);
}
/**
* Given a normalized path, convert it to the system path style. On Windows, switch to \, otherwise use /.
*/
export function unnormalizePath(path: string): string {
return nodePath.normalize(path);
return systemPath.normalize(path);
}
export const CSS_EXTENSIONS = ['css', 'scss', 'sass', 'less', 'styl', 'stylus'];
+15 -10
View File
@@ -4,14 +4,14 @@ import { getUnimportOptions } from '~/core/utils/unimport';
import * as vite from 'vite';
import { extname } from 'path';
const ENABLED_EXTENSIONS: Record<string, boolean | undefined> = {
'.js': true,
'.jsx': true,
'.ts': true,
'.tsx': true,
'.vue': true,
'.svelte': true,
};
const ENABLED_EXTENSIONS = new Set([
'.js',
'.jsx',
'.ts',
'.tsx',
'.vue',
'.svelte',
]);
/**
* Inject any global imports defined by unimport
@@ -28,8 +28,13 @@ export function unimport(config: InternalConfig): vite.PluginOption {
await unimport.scanImportsFromDir(undefined, { cwd: config.srcDir });
},
async transform(code, id) {
const ext = extname(id);
if (ENABLED_EXTENSIONS[ext]) return unimport.injectImports(code, id);
// Don't transform dependencies
if (id.includes('node_modules')) return;
// Don't transform non-js files
if (!ENABLED_EXTENSIONS.has(extname(id))) return;
return unimport.injectImports(code, id);
},
};
}
+1 -1
View File
@@ -327,7 +327,7 @@ export interface BaseEntrypoint {
* - `named.sandbox.html` &rarr; `named`
* - `named.sandbox/index.html` &rarr; `named`
* - `sandbox.html` &rarr; `sandbox`
* - `sandbox.index.html` &rarr; `sandbox`
* - `sandbox/index.html` &rarr; `sandbox`
* - `overlay.content.ts` &rarr; `overlay`
* - `overlay.content/index.ts` &rarr; `overlay`
*
+2 -2
View File
@@ -22,7 +22,7 @@
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@vitejs/plugin-react": "^4.0.3",
"typescript": "^5.1.6",
"wxt": "^0.9.0"
"typescript": "^5.3.2",
"wxt": "^0.10.0"
}
}
+2 -2
View File
@@ -18,8 +18,8 @@
"solid-js": "^1.7.8"
},
"devDependencies": {
"typescript": "^5.1.6",
"typescript": "^5.3.2",
"vite-plugin-solid": "^2.7.0",
"wxt": "^0.9.0"
"wxt": "^0.10.0"
}
}
+2 -2
View File
@@ -19,7 +19,7 @@
"svelte": "^4.0.5",
"svelte-check": "^3.4.6",
"tslib": "^2.6.0",
"typescript": "^5.1.6",
"wxt": "^0.9.0"
"typescript": "^5.3.2",
"wxt": "^0.10.0"
}
}
+2 -2
View File
@@ -15,7 +15,7 @@
"postinstall": "wxt prepare"
},
"devDependencies": {
"typescript": "^5.1.6",
"wxt": "^0.9.0"
"typescript": "^5.3.2",
"wxt": "^0.10.0"
}
}
+2 -2
View File
@@ -19,8 +19,8 @@
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.2.3",
"typescript": "^5.1.6",
"typescript": "^5.3.2",
"vue-tsc": "^1.8.4",
"wxt": "^0.9.0"
"wxt": "^0.10.0"
}
}