vitrify 0.5.3 → 0.5.4

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/app-urls.js CHANGED
@@ -1,5 +1,12 @@
1
1
  // import { resolve } from 'import-meta-resolve'
2
2
  import { existsSync } from 'fs';
3
+ export const resolve = (packageName, base) => {
4
+ const packageUrl = new URL(`./node_modules/${packageName}/`, base);
5
+ if (existsSync(packageUrl.pathname)) {
6
+ return new URL('./', packageUrl);
7
+ }
8
+ throw new Error(`Package ${packageName} not found in ${base.pathname}.`);
9
+ };
3
10
  export const getPkgJsonDir = (dir) => {
4
11
  const pkgJsonPath = new URL('package.json', dir);
5
12
  if (existsSync(pkgJsonPath.pathname)) {
package/dist/index.js CHANGED
@@ -6,9 +6,9 @@ import path from 'path';
6
6
  import { pathToFileURL } from 'url';
7
7
  import { readFileSync } from 'fs';
8
8
  import builtinModules from 'builtin-modules';
9
- import { resolve } from 'import-meta-resolve';
9
+ // import { resolve } from 'import-meta-resolve'
10
10
  import { visualizer } from 'rollup-plugin-visualizer';
11
- import { getPkgJsonDir } from './app-urls.js';
11
+ import { getPkgJsonDir, resolve } from './app-urls.js';
12
12
  const internalServerModules = [
13
13
  'util',
14
14
  'vitrify',
@@ -135,7 +135,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
135
135
  const packageUrls = vitrifyConfig.vitrify?.urls?.packages || {};
136
136
  await (async () => {
137
137
  for (const val of localPackages)
138
- packageUrls[val] = getPkgJsonDir(new URL(await resolve(val, appDir.href)));
138
+ packageUrls[val] = getPkgJsonDir(new URL(await resolve(val, appDir)));
139
139
  })();
140
140
  // await (async () => {
141
141
  // for (const val of cliPackages)
@@ -375,7 +375,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
375
375
  if (command === 'test')
376
376
  alias.push({
377
377
  find: 'vitest',
378
- replacement: new URL(await resolve('vitest', cliDir.href)).pathname
378
+ replacement: new URL(await resolve('vitest', cliDir)).pathname
379
379
  });
380
380
  let rollupOptions = {};
381
381
  let noExternal = [
@@ -3,8 +3,7 @@ import Components from 'unplugin-vue-components/vite';
3
3
  // import { quasarDir as defaultQuasarDir } from '../app-urls.js'
4
4
  // import { QuasarResolver } from '../resolver.js';
5
5
  import { QuasarResolver } from 'unplugin-vue-components/resolvers';
6
- import { getPkgJsonDir } from '../app-urls.js';
7
- import { resolve } from 'import-meta-resolve';
6
+ import { getPkgJsonDir, resolve } from '../app-urls.js';
8
7
  export const injectSsrContext = (html, ssrContext) => html
9
8
  .replace(/(<html[^>]*)(>)/i, (found, start, end) => {
10
9
  let matches;
@@ -59,7 +58,7 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
59
58
  const localPackages = ['@quasar/extras', 'quasar'];
60
59
  await (async () => {
61
60
  for (const val of localPackages)
62
- urls.packages[val] = getPkgJsonDir(new URL(await resolve(val, urls.app.href)));
61
+ urls.packages[val] = getPkgJsonDir(new URL(await resolve(val, urls.app)));
63
62
  })();
64
63
  const onMountedHooks = [
65
64
  async (instance) => {
@@ -1,3 +1,4 @@
1
+ export declare const resolve: (packageName: string, base: URL) => URL;
1
2
  export declare const getPkgJsonDir: (dir: URL) => URL;
2
3
  export declare const getAppDir: () => URL;
3
4
  export declare const getCliDir: () => URL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitrify",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "license": "MIT",
5
5
  "author": "Stefan van Herwijnen",
6
6
  "description": "Pre-configured Vite CLI for your framework",
@@ -64,7 +64,6 @@
64
64
  "fastify": "^4.0.0",
65
65
  "glob": "^8.0.3",
66
66
  "happy-dom": "^5.2.0",
67
- "local-pkg": "^0.4.1",
68
67
  "magic-string": "^0.26.2",
69
68
  "merge-deep": "^3.0.3",
70
69
  "readline": "^1.3.0",
@@ -82,7 +81,6 @@
82
81
  "@types/node": "^17.0.41",
83
82
  "@types/ws": "^8.5.3",
84
83
  "@vue/runtime-core": "^3.2.37",
85
- "import-meta-resolve": "^2.0.3",
86
84
  "quasar": "^2.7.1",
87
85
  "rollup": "^2.75.6",
88
86
  "typescript": "^4.7.3",
@@ -93,7 +91,6 @@
93
91
  "peerDependencies": {
94
92
  "@fastify/static": "^6.4.0",
95
93
  "fastify": "^4.0.0",
96
- "import-meta-resolve": "^2.0.3",
97
94
  "quasar": "^2.7.1",
98
95
  "vue": "^3.2.37",
99
96
  "vue-router": "^4.0.15"
@@ -1,6 +1,14 @@
1
1
  // import { resolve } from 'import-meta-resolve'
2
2
  import { existsSync } from 'fs'
3
3
 
4
+ export const resolve = (packageName: string, base: URL) => {
5
+ const packageUrl = new URL(`./node_modules/${packageName}/`, base)
6
+ if (existsSync(packageUrl.pathname)) {
7
+ return new URL('./', packageUrl)
8
+ }
9
+ throw new Error(`Package ${packageName} not found in ${base.pathname}.`)
10
+ }
11
+
4
12
  export const getPkgJsonDir = (dir: URL): URL => {
5
13
  const pkgJsonPath = new URL('package.json', dir)
6
14
  if (existsSync(pkgJsonPath.pathname)) {
package/src/node/index.ts CHANGED
@@ -8,7 +8,7 @@ import path from 'path'
8
8
  import { pathToFileURL } from 'url'
9
9
  import { readFileSync } from 'fs'
10
10
  import builtinModules from 'builtin-modules'
11
- import { resolve } from 'import-meta-resolve'
11
+ // import { resolve } from 'import-meta-resolve'
12
12
  import { visualizer } from 'rollup-plugin-visualizer'
13
13
  import type {
14
14
  StaticImports,
@@ -21,7 +21,7 @@ import type {
21
21
  } from './vitrify-config.js'
22
22
  import type { VitrifyContext } from './bin/run.js'
23
23
  import type { VitrifyPlugin } from './plugins/index.js'
24
- import { getPkgJsonDir } from './app-urls.js'
24
+ import { getPkgJsonDir, resolve } from './app-urls.js'
25
25
  import type { ManualChunksOption, RollupOptions } from 'rollup'
26
26
 
27
27
  const internalServerModules = [
@@ -198,9 +198,7 @@ export const baseConfig = async ({
198
198
  vitrifyConfig.vitrify?.urls?.packages || {}
199
199
  await (async () => {
200
200
  for (const val of localPackages)
201
- packageUrls[val] = getPkgJsonDir(
202
- new URL(await resolve(val, appDir!.href))
203
- )
201
+ packageUrls[val] = getPkgJsonDir(new URL(await resolve(val, appDir)))
204
202
  })()
205
203
 
206
204
  // await (async () => {
@@ -458,7 +456,7 @@ export const baseConfig = async ({
458
456
  if (command === 'test')
459
457
  alias.push({
460
458
  find: 'vitest',
461
- replacement: new URL(await resolve('vitest', cliDir!.href)).pathname
459
+ replacement: new URL(await resolve('vitest', cliDir)).pathname
462
460
  })
463
461
 
464
462
  let rollupOptions: RollupOptions = {}
@@ -12,9 +12,9 @@ import type {
12
12
  // import { QuasarResolver } from '../resolver.js';
13
13
  import { QuasarResolver } from 'unplugin-vue-components/resolvers'
14
14
  import type { VitrifyPlugin } from './index.js'
15
- import { getPkgJsonDir } from '../app-urls.js'
15
+ import { getPkgJsonDir, resolve } from '../app-urls.js'
16
16
 
17
- import { resolve } from 'import-meta-resolve'
17
+ // import { resolve } from 'import-meta-resolve'
18
18
 
19
19
  export interface QuasarConf {
20
20
  ctx: Record<string, any>
@@ -123,7 +123,7 @@ export const QuasarPlugin: VitrifyPlugin = async ({
123
123
  await (async () => {
124
124
  for (const val of localPackages)
125
125
  urls!.packages![val] = getPkgJsonDir(
126
- new URL(await resolve(val, urls!.app!.href))
126
+ new URL(await resolve(val, urls!.app!))
127
127
  )
128
128
  })()
129
129
 
@@ -4,22 +4,21 @@ import { getAppDir } from '../../../node/app-urls.js'
4
4
  import { onRendered, onSetup } from 'virtual:vitrify-hooks'
5
5
  import { fastifyCsrPlugin } from './fastify-csr-plugin.js'
6
6
  import type { ViteDevServer } from 'vite'
7
- import * as imr from 'import-meta-resolve'
8
- const { resolve } = imr
7
+
9
8
  // const appDir = getPkgJsonDir(import.meta.url)
10
9
  const getString = (str?: string) => str
11
10
  let baseUrl = getString(__BASE_URL__)
12
11
  const appDir = getAppDir()
13
12
 
14
13
  export const setupApp = async () => {
15
- const vitrifyDir = new URL('../', await resolve('vitrify', import.meta.url))
14
+ // const vitrifyDir = new URL('../', await resolve('vitrify', new URL(import.meta.url)))
16
15
  return createApp({
17
16
  onSetup,
18
17
  appDir,
19
18
  baseUrl,
20
19
  onRendered,
21
20
  fastifyPlugin: fastifyCsrPlugin,
22
- vitrifyDir,
21
+ // vitrifyDir,
23
22
  mode: import.meta.env.MODE
24
23
  })
25
24
  }
@@ -4,22 +4,21 @@ import { getAppDir } from '../../../node/app-urls.js'
4
4
  import { onRendered, onSetup } from 'virtual:vitrify-hooks'
5
5
  import { fastifySsrPlugin } from './fastify-ssr-plugin.js'
6
6
  import type { ViteDevServer } from 'vite'
7
- import * as imr from 'import-meta-resolve'
8
- const { resolve } = imr
7
+
9
8
  // const appDir = getPkgJsonDir(import.meta.url)
10
9
  const getString = (str?: string) => str
11
10
  let baseUrl = getString(__BASE_URL__)
12
11
  const appDir = getAppDir()
13
12
 
14
13
  export const setupApp = async () => {
15
- const vitrifyDir = new URL('../', await resolve('vitrify', import.meta.url))
14
+ // const vitrifyDir = new URL('../', await resolve('vitrify', new URL(import.meta.url)))
16
15
  return createApp({
17
16
  onSetup,
18
17
  appDir,
19
18
  baseUrl,
20
19
  onRendered,
21
20
  fastifyPlugin: fastifySsrPlugin,
22
- vitrifyDir,
21
+ // vitrifyDir,
23
22
  mode: import.meta.env.MODE
24
23
  })
25
24
  }