tsconfig fix (#752)

This commit is contained in:
Fred K. Schott 2021-07-19 18:23:39 -07:00 committed by GitHub
parent 11100d62ef
commit a7e66666e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 49 additions and 33 deletions

View file

@ -0,0 +1,7 @@
---
'astro': patch
'@astrojs/parser': patch
'create-astro': patch
---
compile javascript to target Node v12.x

View file

@ -54,7 +54,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [14.x, 16.x]
node-version: [12.x, 14.x, 16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}

View file

@ -6,7 +6,7 @@ import authorData from '../data/authors.json';
const { content } = Astro.props;
---
<html lang={ content.lang ?? 'en' }>
<html lang={ content.lang || 'en' }>
<head>
<title>{content.title}</title>
<MainHead title={content.title} description={content.description} image={content.image} canonicalURL={Astro.request.canonicalURL} />

View file

@ -7,7 +7,7 @@ import BlogPost from '../components/BlogPost.astro';
const {content} = Astro.props;
const {title, description, publishDate, author, heroImage, permalink} = content;
---
<html lang={ content.lang ?? 'en' }>
<html lang={ content.lang || 'en' }>
<head>
<BaseHead title={title} description={description} permalink={permalink} />
<link rel="stylesheet" href="/blog.css" />

View file

@ -10,7 +10,7 @@ import DocSidebar from '../components/DocSidebar.tsx';
// It will run during the build, but never in the browser.
// All variables are available to use in the HTML template below.
const { content } = Astro.props;
const headers = content?.astro?.headers;
const headers = content.astro.headers;
const currentPage = Astro.request.url.pathname;
const currentFile = currentPage === '/' ? 'src/pages/index.md' : `src/pages${currentPage.replace(/\/$/, "")}.md`;
const githubEditUrl = `https://github.com/USER/REPO/blob/main/${currentFile}`
@ -18,7 +18,7 @@ const githubEditUrl = `https://github.com/USER/REPO/blob/main/${currentFile}`
// Full Astro Component Syntax:
// https://docs.astro.build/core-concepts/astro-components/
---
<html lang={ content.lang ?? 'en' }>
<html lang={ content.lang || 'en' }>
<head>
<title>{content.title}</title>

View file

@ -6,7 +6,7 @@ import Nav from '../components/Nav/index.jsx';
const { content } = Astro.props;
---
<html lang={ content.lang ?? 'en' }>
<html lang={ content.lang || 'en' }>
<head>
<MainHead title={content.title} />
<style lang="scss">

View file

@ -8,7 +8,7 @@ const { content } = Astro.props;
---
<!doctype html>
<html lang={ content.lang ?? 'en' }>
<html lang={ content.lang || 'en' }>
<head>
<style>

View file

@ -8,7 +8,7 @@ const { content } = Astro.props;
---
<!doctype html>
<html lang={ content.lang ?? 'en' }>
<html lang={ content.lang || 'en' }>
<head>
<BaseHead title={content.title} description={content.description} permalink="TODO" />

View file

@ -7,7 +7,7 @@ const { content } = Astro.props;
---
<!doctype html>
<html lang={ content.lang ?? 'en' }>
<html lang={ content.lang || 'en' }>
<head>
<style lang="scss">

View file

@ -2,7 +2,7 @@
const { content } = Astro.props;
---
<html lang={ content.lang ?? 'en' }>
<html lang={ content.lang || 'en' }>
<head>
<meta charset="utf-8" />
<title>{content.title}</title>

View file

@ -2,7 +2,7 @@
const { content } = Astro.props;
---
<html lang={ content.lang ?? 'en' }>
<html lang={ content.lang || 'en' }>
<head>
<meta charset="utf-8">
<title>{content.title}</title>

View file

@ -64,6 +64,6 @@
"uvu": "^0.5.1"
},
"engines": {
"node": ">=14.15.1"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}
}

View file

@ -2,7 +2,7 @@
"extends": "../../tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"target": "ES2020",
"target": "ES2019",
"module": "CommonJS",
"outDir": "./dist"
}

View file

@ -140,9 +140,9 @@ async function __render(props, ...children) {
const Astro = {
...__TopLevelAstro,
props,
css: props[__astroInternal]?.css || [],
request: props[__astroInternal]?.request || {},
isPage: props[__astroInternal]?.isPage || false,
css: (props[__astroInternal] && props[__astroInternal].css) || [],
request: (props[__astroInternal] && props[__astroInternal].request) || {},
isPage: (props[__astroInternal] && props[__astroInternal].isPage) || false,
};
${result.script}

View file

@ -8,6 +8,10 @@ const Builtins = suite('Node builtins');
setup(Builtins, './fixtures/builtins');
Builtins('Can be used with the node: prefix', async ({ runtime }) => {
// node:fs/promise is not supported in Node v12. Test currently throws.
if (process.versions.node <= '13') {
return;
}
const result = await runtime.load('/');
if (result.error) throw new Error(result.error);

View file

@ -1,6 +1,6 @@
import { fileURLToPath } from 'url';
import { build as astroBuild } from '#astro/build';
import { readFile } from 'fs/promises';
import { readFileSync } from 'fs';
import { createRuntime } from '#astro/runtime';
import { loadConfig } from '#astro/config';
import execa from 'execa';
@ -86,7 +86,7 @@ export function setupBuild(Suite, fixturePath) {
context.build = () => astroBuild(astroConfig, { level: 'error', dest: process.stderr });
context.readFile = async (path) => {
const resolved = fileURLToPath(new URL(`${fixturePath}/${astroConfig.dist}${path}`, import.meta.url));
return readFile(resolved).then((r) => r.toString('utf8'));
return readFileSync(resolved, {encoding: 'utf8'});
};
clearTimeout(timeout);

View file

@ -8,6 +8,10 @@ const LitElement = suite('LitElement test');
setup(LitElement, './fixtures/lit-element');
LitElement('Renders a custom element by tag name', async ({ runtime }) => {
// lit SSR is not currently supported on Node.js < 13
if (process.versions.node <= '13') {
return;
}
const result = await runtime.load('/');
if (result.error) throw new Error(result.error);
@ -30,7 +34,7 @@ LitElement.skip('Renders a custom element by the constructor', async ({ runtime
// The Lit renderer adds browser globals that interfere with other tests, so remove them now.
LitElement.after(() => {
const globals = Object.keys(globalThis.window);
const globals = Object.keys(globalThis.window || {});
globals.splice(globals.indexOf('global'), 1);
for (let name of globals) {
delete globalThis[name];

View file

@ -3,7 +3,7 @@
"include": ["src", "index.d.ts"],
"compilerOptions": {
"allowJs": true,
"target": "ES2020",
"target": "ES2019",
"module": "ES2020",
"outDir": "./dist",
"declarationDir": "./dist/types"

View file

@ -3,7 +3,7 @@
"include": ["src", "index.d.ts"],
"compilerOptions": {
"allowJs": true,
"target": "ES2020",
"target": "ES2019",
"module": "ES2020",
"outDir": "./dist",
"declarationDir": "./dist/types"

View file

@ -3,7 +3,7 @@
"include": ["src"],
"compilerOptions": {
"allowJs": true,
"target": "ES2020",
"target": "ES2019",
"module": "ES2020",
"outDir": "./dist"
}

View file

@ -3,11 +3,10 @@ async function polyfill() {
hydrateShadowRoots(document.body);
}
if (
!new DOMParser()
.parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', {
includeShadowRoots: true,
})
.querySelector('p')?.shadowRoot
)
const polyfillCheckEl = new DOMParser()
.parseFromString(`<p><template shadowroot="open"></template></p>`, 'text/html', {includeShadowRoots: true})
.querySelector('p');
if (!polyfillCheckEl || !polyfillCheckEl.shadowRoot) {
polyfill();
}

View file

@ -10,7 +10,9 @@ const defaultConfig = {
minify: false,
format: 'esm',
platform: 'node',
target: 'node14.16.1',
// There's an issue with 'node12.20' compiling ESM to CJS
// so use 'node13.2' instead. V8 support should be similar.
target: 'node13.2',
sourcemap: 'inline',
sourcesContent: false,
};
@ -63,7 +65,7 @@ export default async function build(...args) {
});
process.on('beforeExit', () => {
builder.stop?.();
builder.stop && builder.stop();
});
}

View file

@ -5,12 +5,12 @@ export default async function run() {
case 'dev':
case 'build': {
const { default: build } = await import('./cmd/build.js');
build(...args, cmd === 'dev' ? 'IS_DEV' : undefined);
await build(...args, cmd === 'dev' ? 'IS_DEV' : undefined);
break;
}
case 'copy': {
const { default: copy } = await import('./cmd/copy.js');
copy(...args);
await copy(...args);
break;
}
}