diff --git a/packages/start/fs-router/fileRoutesImport.ts b/packages/start/fs-router/fileRoutesImport.js similarity index 76% rename from packages/start/fs-router/fileRoutesImport.ts rename to packages/start/fs-router/fileRoutesImport.js index c287af52a..1ebc4b57d 100644 --- a/packages/start/fs-router/fileRoutesImport.ts +++ b/packages/start/fs-router/fileRoutesImport.js @@ -1,21 +1,7 @@ -// @ts-ignore -import type * as BabelTypes from "@babel/types/lib"; - -type Path = { - node: { body: any; source: { value: string; }; specifiers: any[]; }; - scope: { generateUidIdentifier: (arg0: string) => any; }; - replaceWith: (arg0: any) => void; - insertBefore: (arg0: any) => void; -} - -type State = { - namespaceSpec: any[]; -} - -export default function fileRoutesImport({ types: t }: { types: typeof BabelTypes }) { +export default function fileRoutesImport({ types: t }) { return { visitor: { - ImportDeclaration(path: Path, state: State) { + ImportDeclaration(path, state) { if (path.node.source.value !== "solid-start") { return; } @@ -43,12 +29,12 @@ export default function fileRoutesImport({ types: t }: { types: typeof BabelType } }, Program: { - enter(_path: Path, state: State) { + enter(_path, state) { state.namespaceSpec = []; }, - exit(path: Path, state: State) { + exit(path, state) { const body = path.node.body; - let lastImportIndex: number; + let lastImportIndex; if (state.namespaceSpec.length) { for (let i = 0; i < body.length; i++) { if (body[i].type === "ImportDeclaration") { @@ -63,7 +49,7 @@ export default function fileRoutesImport({ types: t }: { types: typeof BabelType t.stringLiteral("solid-start/root/FileRoutes") ); body.unshift(newImport); - lastImportIndex!++; + lastImportIndex++; const namespaceId = path.scope.generateUidIdentifier(specifier.local.name); const namespaceFix = t.variableDeclaration("const", [ t.variableDeclarator( @@ -74,7 +60,7 @@ export default function fileRoutesImport({ types: t }: { types: typeof BabelType ]) ) ]); - body.splice(lastImportIndex! + 1, 0, namespaceFix); + body.splice(lastImportIndex + 1, 0, namespaceFix); specifier.local.name = namespaceId.name; } } diff --git a/packages/start/fs-router/manifest.js b/packages/start/fs-router/manifest.js index 529e8be67..cc69417c0 100644 --- a/packages/start/fs-router/manifest.js +++ b/packages/start/fs-router/manifest.js @@ -1,6 +1,6 @@ // make asset lookup import { posix } from "path"; -import { toPath } from "./path-utils.ts"; +import { toPath } from "./path-utils.js"; /** * Output: diff --git a/packages/start/fs-router/path-utils.ts b/packages/start/fs-router/path-utils.js similarity index 79% rename from packages/start/fs-router/path-utils.ts rename to packages/start/fs-router/path-utils.js index 74b9b83f0..123693dbc 100644 --- a/packages/start/fs-router/path-utils.ts +++ b/packages/start/fs-router/path-utils.js @@ -3,11 +3,11 @@ * @param removePathlessLayouts * @returns */ -export function toPath(id: string, removePathlessLayouts = true): string { +export function toPath(id, removePathlessLayouts = true) { const idWithoutIndex = id.endsWith("/index") ? id.slice(0, -"index".length) : id; return ( removePathlessLayouts ? idWithoutIndex.replace(/\/\([^)/]+\)/g, "") : idWithoutIndex - ).replace(/\[([^\/]+)\]/g, (_, m: string) => { + ).replace(/\[([^\/]+)\]/g, (_, m) => { if (m.length > 3 && m.startsWith("...")) { return `*${m.slice(3)}`; } diff --git a/packages/start/fs-router/router.js b/packages/start/fs-router/router.js index 2d3de1469..74ad782c7 100644 --- a/packages/start/fs-router/router.js +++ b/packages/start/fs-router/router.js @@ -6,7 +6,7 @@ import esbuild from "esbuild"; import fg from "fast-glob"; import fs from "fs"; import path, { join } from "path"; -import { toPath } from "./path-utils.ts"; +import { toPath } from "./path-utils.js"; const log = debug("solid-start"); const ROUTE_KEYS = ["component", "path", "data", "children"]; diff --git a/packages/start/package.json b/packages/start/package.json index 176bbff55..b38117798 100644 --- a/packages/start/package.json +++ b/packages/start/package.json @@ -109,7 +109,6 @@ "wait-on": "^6.0.1" }, "devDependencies": { - "@babel/types": "^7.20.7", "@cloudflare/workers-types": "^3.19.0", "@solidjs/meta": "^0.28.2", "@solidjs/router": "^0.7.0", diff --git a/packages/start/vite/plugin.js b/packages/start/vite/plugin.js index a8078ca73..c91ae9db6 100644 --- a/packages/start/vite/plugin.js +++ b/packages/start/vite/plugin.js @@ -11,7 +11,7 @@ import { loadEnv, normalizePath } from "vite"; import inspect from "vite-plugin-inspect"; import solid from "vite-plugin-solid"; import printUrls from "../dev/print-routes.js"; -import fileRoutesImport from "../fs-router/fileRoutesImport.ts"; +import fileRoutesImport from "../fs-router/fileRoutesImport.js"; import { Router, stringifyApiRoutes, stringifyPageRoutes } from "../fs-router/router.js"; import routeData from "../server/routeData.js"; import routeDataHmr from "../server/routeDataHmr.js"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d2812067d..6d74d8583 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -452,7 +452,6 @@ importers: '@babel/preset-env': ^7.20.2 '@babel/preset-typescript': ^7.18.6 '@babel/template': ^7.20.7 - '@babel/types': ^7.20.7 '@cloudflare/workers-types': ^3.19.0 '@solidjs/meta': ^0.28.2 '@solidjs/router': ^0.7.0 @@ -532,7 +531,6 @@ importers: vite-plugin-solid: 2.5.0_solid-js@1.6.9+vite@3.2.5 wait-on: 6.0.1_debug@4.3.4 devDependencies: - '@babel/types': 7.20.7 '@cloudflare/workers-types': 3.19.0 '@solidjs/meta': 0.28.2_solid-js@1.6.9 '@solidjs/router': 0.7.0_solid-js@1.6.9 @@ -3219,7 +3217,7 @@ packages: /axios/0.25.0_debug@4.3.4: resolution: {integrity: sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g==} dependencies: - follow-redirects: 1.15.2_debug@4.3.4 + follow-redirects: 1.15.2 transitivePeerDependencies: - debug dev: false @@ -4817,17 +4815,6 @@ packages: optional: true dev: false - /follow-redirects/1.15.2_debug@4.3.4: - resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==} - engines: {node: '>=4.0'} - peerDependencies: - debug: '*' - peerDependenciesMeta: - debug: - optional: true - dependencies: - debug: 4.3.4 - /for-each/0.3.3: resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} dependencies: @@ -6680,6 +6667,17 @@ packages: trouter: 3.2.0 dev: false + /postcss-import/14.1.0: + resolution: {integrity: sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==} + engines: {node: '>=10.0.0'} + peerDependencies: + postcss: ^8.0.0 + dependencies: + postcss-value-parser: 4.2.0 + read-cache: 1.0.0 + resolve: 1.22.1 + dev: true + /postcss-import/14.1.0_postcss@8.4.21: resolution: {integrity: sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==} engines: {node: '>=10.0.0'} @@ -6692,6 +6690,15 @@ packages: resolve: 1.22.1 dev: true + /postcss-js/4.0.0: + resolution: {integrity: sha512-77QESFBwgX4irogGVPgQ5s07vLvFqWr228qZY+w6lW599cRlK/HmnlivnnVUxkjHnCu4J16PDMHcH+e+2HbvTQ==} + engines: {node: ^12 || ^14 || >= 16} + peerDependencies: + postcss: ^8.3.3 + dependencies: + camelcase-css: 2.0.1 + dev: true + /postcss-js/4.0.0_postcss@8.4.21: resolution: {integrity: sha512-77QESFBwgX4irogGVPgQ5s07vLvFqWr228qZY+w6lW599cRlK/HmnlivnnVUxkjHnCu4J16PDMHcH+e+2HbvTQ==} engines: {node: ^12 || ^14 || >= 16} @@ -6702,6 +6709,22 @@ packages: postcss: 8.4.21 dev: true + /postcss-load-config/3.1.4: + resolution: {integrity: sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==} + engines: {node: '>= 10'} + peerDependencies: + postcss: '>=8.0.9' + ts-node: '>=9.0.0' + peerDependenciesMeta: + postcss: + optional: true + ts-node: + optional: true + dependencies: + lilconfig: 2.0.6 + yaml: 1.10.2 + dev: true + /postcss-load-config/3.1.4_postcss@8.4.21: resolution: {integrity: sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==} engines: {node: '>= 10'} @@ -6719,6 +6742,15 @@ packages: yaml: 1.10.2 dev: true + /postcss-nested/6.0.0: + resolution: {integrity: sha512-0DkamqrPcmkBDsLn+vQDIrtkSbNkv5AD/M322ySo9kqFkCIYklym2xEmWkwo+Y3/qZo34tzEPNUw4y7yMCdv5w==} + engines: {node: '>=12.0'} + peerDependencies: + postcss: ^8.2.14 + dependencies: + postcss-selector-parser: 6.0.11 + dev: true + /postcss-nested/6.0.0_postcss@8.4.21: resolution: {integrity: sha512-0DkamqrPcmkBDsLn+vQDIrtkSbNkv5AD/M322ySo9kqFkCIYklym2xEmWkwo+Y3/qZo34tzEPNUw4y7yMCdv5w==} engines: {node: '>=12.0'} @@ -7546,6 +7578,8 @@ packages: resolution: {integrity: sha512-AhwtHCKMtR71JgeYDaswmZXhPcW9iuI9Sp2LvZPo9upDZ7231ZJ7eA9RaURbhpXGVlrjX4cFNlB4ieTetEb7hQ==} engines: {node: '>=12.13.0'} hasBin: true + peerDependencies: + postcss: ^8.0.9 dependencies: arg: 5.0.2 chokidar: 3.5.3 @@ -7561,11 +7595,10 @@ packages: normalize-path: 3.0.0 object-hash: 3.0.0 picocolors: 1.0.0 - postcss: 8.4.21 - postcss-import: 14.1.0_postcss@8.4.21 - postcss-js: 4.0.0_postcss@8.4.21 - postcss-load-config: 3.1.4_postcss@8.4.21 - postcss-nested: 6.0.0_postcss@8.4.21 + postcss-import: 14.1.0 + postcss-js: 4.0.0 + postcss-load-config: 3.1.4 + postcss-nested: 6.0.0 postcss-selector-parser: 6.0.11 postcss-value-parser: 4.2.0 quick-lru: 5.1.1