Pass mode into snowpack runtime (#99)

* Pass the `mode` through to snowpack

This allows the production packages to be prepared.

* Use snowpack 3.3.1

* Update path to prism loadComponents external ref

* Upgrade to snowpack 3.3.2
This commit is contained in:
Matthew Phillips 2021-04-16 13:15:27 -04:00 committed by GitHub
parent 2a7aa765b4
commit 58c499dc85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 2364 additions and 269 deletions

View file

@ -1,7 +1,7 @@
---
import Prism from 'prismjs';
import { addAstro } from '../astro-prism/index.mjs';
import * as loadLanguages from 'prismjs/components/';
import * as loadLanguages from 'prismjs/components/index.js';
export let lang;
export let code;

File diff suppressed because it is too large Load diff

1219
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -68,7 +68,7 @@
"rollup": "^2.43.1",
"rollup-plugin-terser": "^7.0.2",
"sass": "^1.32.8",
"snowpack": "^3.2.2",
"snowpack": "^3.3.2",
"svelte": "^3.35.0",
"tiny-glob": "^0.2.8",
"unified": "^9.2.1",

View file

@ -243,7 +243,6 @@ export const parse_expression_at = (source: string, index: number): Expression =
// @ts-ignore
export default function read_expression(parser: Parser) {
try {
debugger;
const expression = parse_expression_at(parser.template, parser.index);
parser.index = expression.end;
return expression;

View file

@ -230,7 +230,7 @@ interface RuntimeOptions {
}
/** Create a new Snowpack instance to power Astro */
async function createSnowpack(astroConfig: AstroConfig, env: Record<string, any>) {
async function createSnowpack(astroConfig: AstroConfig, env: Record<string, any>, mode: RuntimeMode) {
const { projectRoot, astroRoot, extensions } = astroConfig;
const internalPath = new URL('./frontend/', import.meta.url);
@ -258,6 +258,7 @@ async function createSnowpack(astroConfig: AstroConfig, env: Record<string, any>
const snowpackConfig = await loadConfiguration({
root: fileURLToPath(projectRoot),
mount: mountOptions,
mode: mode,
plugins: [
[fileURLToPath(new URL('../snowpack-plugin.cjs', import.meta.url)), astroPlugOptions],
require.resolve('@snowpack/plugin-sass'),
@ -274,7 +275,7 @@ async function createSnowpack(astroConfig: AstroConfig, env: Record<string, any>
},
packageOptions: {
knownEntrypoints: ['preact-render-to-string'],
external: ['@vue/server-renderer', 'node-fetch', 'prismjs/components/'],
external: ['@vue/server-renderer', 'node-fetch', 'prismjs/components/index.js'],
},
});
@ -294,11 +295,11 @@ async function createSnowpack(astroConfig: AstroConfig, env: Record<string, any>
export async function createRuntime(astroConfig: AstroConfig, { mode, logging }: RuntimeOptions): Promise<AstroRuntime> {
const { snowpack: backendSnowpack, snowpackRuntime: backendSnowpackRuntime, snowpackConfig: backendSnowpackConfig } = await createSnowpack(astroConfig, {
astro: true,
});
}, mode);
const { snowpack: frontendSnowpack, snowpackRuntime: frontendSnowpackRuntime, snowpackConfig: frontendSnowpackConfig } = await createSnowpack(astroConfig, {
astro: false,
});
}, mode);
const runtimeConfig: RuntimeConfig = {
astroConfig,

View file

@ -5,7 +5,6 @@ import { createRuntime } from '../lib/runtime.js';
import { loadConfig } from '../lib/config.js';
import { promises as fsPromises } from 'fs';
import { relative as pathRelative } from 'path';
import { doc } from './test-utils.js';
const { readdir, stat } = fsPromises;