refactor: add more tructure to runtime dir

This commit is contained in:
Pooya Parsa 2020-11-11 15:03:55 +01:00
parent aff2372650
commit 8414e64eeb
6 changed files with 7 additions and 6 deletions

View File

@ -102,9 +102,9 @@ export const getRollupConfig = (config: SLSOptions) => {
options.plugins.push(alias({ options.plugins.push(alias({
entries: { entries: {
'~runtime': config.runtimeDir, '~runtime': config.runtimeDir,
'~renderer': require.resolve(resolve(config.runtimeDir, renderer)), '~renderer': require.resolve(resolve(config.runtimeDir, 'ssr', renderer)),
'~build': config.buildDir, '~build': config.buildDir,
'~mock': require.resolve(resolve(config.runtimeDir, 'mock')), '~mock': require.resolve(resolve(config.runtimeDir, 'utils/mock')),
...mocks.reduce((p, c) => ({ ...p, [c]: '~mock' }), {}), ...mocks.reduce((p, c) => ({ ...p, [c]: '~mock' }), {}),
...providedDeps.reduce((p, c) => ({ ...p, [c]: require.resolve(c) }), {}) ...providedDeps.reduce((p, c) => ({ ...p, [c]: require.resolve(c) }), {})
} }

View File

@ -15,6 +15,7 @@ if ('serviceWorker' in navigator) {
</script>`.replace(/\n| +/g, '') </script>`.replace(/\n| +/g, '')
return { return {
entry: '{{ runtimeDir }}/targets/service-worker',
targetDir: '{{ publicDir }}', targetDir: '{{ publicDir }}',
nuxtHooks: { nuxtHooks: {
'vue-renderer:ssr:templateParams' (params) { 'vue-renderer:ssr:templateParams' (params) {

View File

@ -5,7 +5,7 @@ import { SLSOptions, SLSTarget } from '../config'
import { worker } from './worker' import { worker } from './worker'
export const cloudflare: SLSTarget = extendTarget(worker, { export const cloudflare: SLSTarget = extendTarget(worker, {
entry: '{{ runtimeDir }}/cloudflare', entry: '{{ runtimeDir }}/targets/cloudflare',
generateIgnore: [ generateIgnore: [
'wrangler.toml' 'wrangler.toml'
], ],

View File

@ -4,7 +4,7 @@ import consola from 'consola'
import { SLSTarget } from '../config' import { SLSTarget } from '../config'
export const lambda: SLSTarget = { export const lambda: SLSTarget = {
entry: '{{ runtimeDir }}/lambda', entry: '{{ runtimeDir }}/targets/lambda',
hooks: { hooks: {
'done' ({ rollupConfig }) { 'done' ({ rollupConfig }) {
const entry = relative(process.cwd(), rollupConfig.output.file).replace(/\.js$/, '') const entry = relative(process.cwd(), rollupConfig.output.file).replace(/\.js$/, '')

View File

@ -3,7 +3,7 @@ import consola from 'consola'
import { SLSTarget } from '../config' import { SLSTarget } from '../config'
export const node: SLSTarget = { export const node: SLSTarget = {
entry: '{{ runtimeDir }}/node', entry: '{{ runtimeDir }}/targets/node',
hooks: { hooks: {
'done' ({ rollupConfig }) { 'done' ({ rollupConfig }) {
const entry = relative(process.cwd(), rollupConfig.output.file).replace(/\.js$/, '') const entry = relative(process.cwd(), rollupConfig.output.file).replace(/\.js$/, '')

View File

@ -12,7 +12,7 @@ const o=Date.now(),t=()=>Date.now()-o;process.hrtime=o=>{const e=Math.floor(.001
` `
export const worker: SLSTarget = { export const worker: SLSTarget = {
entry: '{{ runtimeDir }}/worker', entry: null, // Abstract
node: false, node: false,
hooks: { hooks: {
'rollup:before' ({ rollupConfig }) { 'rollup:before' ({ rollupConfig }) {