This repository was archived by the owner on Jul 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
feat: template improvements #74
Open
danielroe
wants to merge
23
commits into
template
Choose a base branch
from
template-improvements
base: template
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
5952733
chore: remove `yarn.lock` to ensure latest dependencies are installed
danielroe f0be496
refactor: various module template improvements
danielroe 4e7d31a
refactor: use `src/templates` folder for compiled templates with live…
danielroe 8030480
test: fix test suite
danielroe 9be885b
ci: test on node 12/14
danielroe 034d079
ci: add branch name
danielroe e9932ad
style: fix out-of-the-box lint errors
danielroe 5302f94
ci: restore lockfile for cacheable runs and update scripts
danielroe 5976480
test: fix race condition
danielroe ec4e0c9
test: update test for window support
danielroe dabc36a
ci: temporarily run tests against PR
danielroe 9e0c159
test: normalise setup
danielroe 8febc52
ci: cache playwright
danielroe 5a97ec8
test: fix
danielroe bd3dc68
test: simplify
danielroe 02dd68b
ci: use recommended approach for cache and test fewer targets
danielroe 6f89ac1
test: collect coverage from templates
danielroe 69ddb3d
test: remove src/templates from coverage
danielroe 0659223
ci: add node_modules to cache folder
danielroe a95c652
ci: always install dependencies
danielroe b34a8dd
fix: insert typescript plugins in fixture
danielroe 4f4408d
chore: remove explicit `typescript` dep
danielroe ea7efa3
ci: remove temporary branch target
danielroe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export default { | ||
modules: [ | ||
'@nuxt/typescript-build', | ||
'../src/module.ts' | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -8,6 +8,9 @@ module.exports = { | |||||||
} | ||||||||
] | ||||||||
}, | ||||||||
moduleNameMapper: { | ||||||||
npm_package: '<rootDir>/src' | ||||||||
}, | ||||||||
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Looks like this causes issues with importing of other npm packages. |
||||||||
collectCoverage: true, | ||||||||
collectCoverageFrom: ['src/**', '!templates/**'] | ||||||||
collectCoverageFrom: ['src/**'] | ||||||||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,33 @@ | ||
import { resolve } from 'path' | ||
import defu from 'defu' | ||
import { Module } from '@nuxt/types' | ||
import { extname } from 'upath' | ||
|
||
import { Module, NuxtOptions } from '@nuxt/types' | ||
|
||
import { name, version } from '../package.json' | ||
|
||
export interface ModuleOptions {} | ||
const DEFAULTS: ModuleOptions = {} | ||
const CONFIG_KEY = 'myModule' | ||
|
||
const nuxtModule: Module<ModuleOptions> = /* async */ function (moduleOptions) { | ||
const options = defu<ModuleOptions>(this.options[CONFIG_KEY], moduleOptions, DEFAULTS) | ||
// const { nuxt } = this | ||
const options = defu(this.options[CONFIG_KEY] /* istanbul ignore next */ || {}, moduleOptions, DEFAULTS) | ||
|
||
const nuxtOptions: NuxtOptions = this.nuxt.options | ||
console.log('Normalized & typed Nuxt options available, e.g.', { rootDir: nuxtOptions.rootDir }) | ||
|
||
const src = require.resolve('./templates/plugin') | ||
this.addPlugin({ | ||
src: resolve(__dirname, '../templates/plugin.js'), | ||
fileName: 'myPlugin.js', | ||
src, | ||
fileName: 'myPlugin' + extname(src), | ||
options | ||
}) | ||
} | ||
|
||
;(nuxtModule as any).meta = require('../package.json') | ||
;(nuxtModule as any).meta = { name, version } | ||
|
||
declare module '@nuxt/types' { | ||
interface NuxtConfig { [CONFIG_KEY]?: ModuleOptions } // Nuxt 2.14+ | ||
interface Configuration { [CONFIG_KEY]?: ModuleOptions } // Nuxt 2.9 - 2.13 | ||
interface NuxtConfig { [CONFIG_KEY]?: Partial<ModuleOptions> } // Nuxt 2.14+ | ||
interface Configuration { [CONFIG_KEY]?: Partial<ModuleOptions> } // Nuxt 2.9 - 2.13 | ||
} | ||
|
||
export default nuxtModule |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { Plugin } from '@nuxt/types' | ||
|
||
console.log('imported') | ||
|
||
export default <Plugin> /* async */ function (ctx, inject) { | ||
// Fully typed plugin | ||
console.log('loaded', ctx && 'with context', !!inject && 'and with inject') | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.