[READ-ONLY] Mirror of https://github.com/danielroe/nuxt-timings-module.
0

Configure Feed

Select the types of activity you want to include in your feed.

test: remove `moduleNameMapper` from jest code (#1)

+29 -29
+3 -3
example/nuxt.config.js
··· 1 1 export default { 2 2 alias: { 3 - 'nuxt-timings/dist/runtime': require.resolve('../src/runtime/index.ts'), 4 - 'nuxt-timings': require.resolve('../src/index.ts') 3 + 'nuxt-timings/runtime': require.resolve('../src/runtime'), 4 + 'nuxt-timings': require.resolve('../src') 5 5 }, 6 6 modules: [ 7 - '../src/index.ts', 7 + '../src', 8 8 '@nuxt/typescript-build' 9 9 ], 10 10 plugins: [
+1 -5
jest.config.js
··· 9 9 } 10 10 ] 11 11 }, 12 - moduleNameMapper: { 13 - 'nuxt-timings/dist/runtime': '<rootDir>/src/runtime', 14 - 'nuxt-timings': '<rootDir>/src' 15 - }, 16 12 collectCoverage: true, 17 - collectCoverageFrom: ['src/*.ts'] 13 + collectCoverageFrom: ['src/**/*.ts'] 18 14 }
+3 -3
package.json
··· 14 14 "exports": { 15 15 ".": "./dist/index.js", 16 16 "./package.json": "./dist/package.json", 17 - "./dist/templates/*": "./dist/templates/*", 18 - "./dist/runtime": "./dist/runtime" 17 + "./templates/*": "./dist/templates/*", 18 + "./runtime": "./dist/runtime.js" 19 19 }, 20 20 "main": "./dist/index.js", 21 21 "types": "./dist/index.d.ts", ··· 29 29 "prepare": "yarn build", 30 30 "prepublishOnly": "yarn test", 31 31 "release": "yarn build && yarn test && release-it", 32 - "test": "yarn lint && yarn build && jest" 32 + "test": "yarn lint && yarn build && yarn jest" 33 33 }, 34 34 "husky": { 35 35 "gitHooks": {
+4 -3
src/fetch.ts
··· 1 - import { resolve } from 'upath' 1 + import { extname } from 'upath' 2 2 3 3 import type { ModuleThis } from '@nuxt/types/config/module' 4 4 5 5 export function registerFetchTimings (this: ModuleThis) { 6 + const src = require.resolve('./templates/fetch') 6 7 this.addPlugin({ 7 - src: resolve(__dirname, '../dist/templates/fetch.js'), 8 - fileName: 'timings-fetch.server.js' 8 + src, 9 + fileName: 'timings-fetch.server' + extname(src) 9 10 }) 10 11 }
+8 -7
src/plugins.ts
··· 1 - import { resolve } from 'upath' 1 + import { extname, resolve } from 'upath' 2 2 3 3 import type { NuxtOptions } from '@nuxt/types' 4 4 import type { ModuleThis } from '@nuxt/types/config/module' ··· 6 6 7 7 function templateFile ( 8 8 this: ModuleThis, 9 - relativeSrc: string, 9 + src: string, 10 10 fileName: string, 11 11 options: Record<string, any> 12 12 ) { 13 13 const { dst } = this.addTemplate({ 14 - src: resolve(__dirname, relativeSrc), 14 + src, 15 15 fileName, 16 16 options 17 17 }) ··· 24 24 nuxtOptions.plugins = nuxtOptions.plugins.reduce((plugins, plugin, index) => { 25 25 const pluginName = (typeof plugin === 'string' ? plugin : plugin.src).replace(nuxtOptions.buildDir + '/', '').replace('~/plugins/', '').replace('~/', '') 26 26 27 + const src = require.resolve('./templates/plugins') 27 28 const before = templateFile.call( 28 29 this, 29 - '../dist/templates/plugins.js', 30 - 'timings-plugins-' + index + 'before.server.js', 30 + src, 31 + 'timings-plugins-' + index + 'before.server' + extname(src), 31 32 { 32 33 plugin: pluginName, 33 34 mode: 'start' ··· 35 36 ) 36 37 const after = templateFile.call( 37 38 this, 38 - '../dist/templates/plugins.js', 39 - 'timings-plugins-' + index + 'after.server.js', 39 + src, 40 + 'timings-plugins-' + index + 'after.server' + extname(src), 40 41 { 41 42 plugin: pluginName, 42 43 mode: 'end'
+4 -3
src/store.ts
··· 1 - import { resolve } from 'upath' 1 + import { extname } from 'upath' 2 2 3 3 import type { ModuleThis } from '@nuxt/types/config/module' 4 4 5 5 export function registerStoreTimings (this: ModuleThis) { 6 + const src = require.resolve('./templates/store') 6 7 this.addPlugin({ 7 - src: resolve(__dirname, '../dist/templates/store.js'), 8 - fileName: 'timings-store.server.js' 8 + src, 9 + fileName: 'timings-store.server' + extname(src) 9 10 }) 10 11 }
+1 -1
src/templates/fetch.ts
··· 1 1 import Vue from 'vue' 2 2 3 - import { prettyTimer, sanitizeString } from 'nuxt-timings/dist/runtime' 3 + import { prettyTimer, sanitizeString } from 'nuxt-timings/runtime' 4 4 5 5 function hasFetch (vm: Vue) { 6 6 return vm.$options && typeof vm.$options.fetch === 'function' && !vm.$options.fetch.length
+1 -1
src/templates/plugins.ts
··· 1 1 import type { Plugin } from '@nuxt/types' 2 2 3 - import { prettyTimer } from 'nuxt-timings/dist/runtime' 3 + import { prettyTimer } from 'nuxt-timings/runtime' 4 4 5 5 const plugin: string = '<%= options.plugin %>' 6 6 const mode = '<%= options.mode %>' as 'start' | 'end'
+1 -1
src/templates/store.ts
··· 1 1 import type { ServerResponse } from 'http' 2 2 import type { Plugin } from '@nuxt/types' 3 3 4 - import { prettyTimer, sanitizeString } from 'nuxt-timings/dist/runtime' 4 + import { prettyTimer, sanitizeString } from 'nuxt-timings/runtime' 5 5 6 6 export function processTiming (res: ServerResponse, oldTiming: string, _newTiming: string, description: string) { 7 7 if (oldTiming) {
+3 -2
tsconfig.json
··· 7 7 "esnext", 8 8 "dom" 9 9 ], 10 + "allowJs": true, 10 11 "esModuleInterop": true, 11 12 "moduleResolution": "node", 12 13 "declaration": false, ··· 18 19 "jest" 19 20 ], 20 21 "paths": { 21 - "nuxt-timings/dist/runtime": ["./src/runtime/index.ts"], 22 - "nuxt-timings": ["./src/index.ts"] 22 + "nuxt-timings": ["./src/index.ts"], 23 + "nuxt-timings/*": ["./src/*"] 23 24 } 24 25 }, 25 26 "exclude": [