Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
node-version: 18.x

# Wireit cache
- uses: google/wireit@setup-github-actions-caching/v1
- uses: google/wireit@setup-github-actions-caching/v2

- name: Install dependencies
run: pnpm install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-spectacle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
node-version: ${{ matrix.node-version }}

# Wireit cache
- uses: google/wireit@setup-github-actions-caching/v1
- uses: google/wireit@setup-github-actions-caching/v2

- name: Install dependencies
run: pnpm install
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.x
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"webpack": "5.76.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.1",
"wireit": "^0.7.2"
"wireit": "^0.14.12"
},
"pnpm": {
"neverBuiltDependencies": [
Expand Down Expand Up @@ -263,4 +263,4 @@
"engines": {
"node": ">=18.0.0"
}
}
}
1 change: 0 additions & 1 deletion packages/create-spectacle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"shx": "^0.3.4",
"spectacle": "*"
},
"resolutions": {},
"scripts": {
"dev": "pnpm copy-spectacle-package && ts-node src/cli.ts",
"build": "wireit",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-spectacle/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const DeckTypeOptions = [
{ title: 'React using webpack', value: 'tsx' }
];

let progressInterval: NodeJS.Timer;
let progressInterval: NodeJS.Timeout;
const log = console.log;
const printConsoleError = (message: string) =>
chalk.whiteBright.bgRed.bold(' ! ') + chalk.red.bold(' ' + message + '\n');
Expand Down
37 changes: 20 additions & 17 deletions packages/create-spectacle/src/generators/one-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@ import { onePageTemplate } from '../templates/one-page';
const spectaclePackage = require(`${__dirname}/../../spectacle-package.json`);
const REACT_VERSION = spectaclePackage.devDependencies.react.replace('^', '');
const ESM_SH_VERSION = 'v121';
const DEVELOPMENT_BUILDS = false; // Enable this to use react.development.mjs etc...

export const generateImportMap = () => {
const importMap = new Map<string, string>();
const { dependencies, peerDependencies } = spectaclePackage;

importMap.set('spectacle', importUrl('spectacle', '10', '?bundle'));
importMap.set('react', importUrl('react', REACT_VERSION));
importMap.set(
'react/jsx-runtime',
importUrl('react', REACT_VERSION, '/jsx-runtime')
);
importMap.set(
'react-dom/client',
importUrl('react-dom', REACT_VERSION, '/client')
);
importMap.set('htm', importUrl('htm', '^3'));
importMap.set('spectacle', 'https://esm.sh/spectacle@10?bundle');

const sortedDeps = <[string, string][]>Object.entries({
...dependencies,
...peerDependencies
}).sort(([a], [b]) => a.localeCompare(b));

for (const [pkg, version] of sortedDeps) {
const dependencies = spectaclePackage.dependencies as Record<string, string>;
for (const [pkg, version] of Object.entries(dependencies)) {
if (importMap.has(pkg)) continue;
importMap.set(pkg, importUrl(pkg, version));
handlePackageExceptions(pkg, version, importMap);
Expand All @@ -30,22 +35,20 @@ export const createOnePage = (name: string, lang: string) => {
return onePageTemplate({ importMap, name, lang });
};

const importUrl = (pkg: string, version: string, extra = '') => {
if (pkg === 'react') version = REACT_VERSION;
return `https://esm.sh/${ESM_SH_VERSION}/${pkg}@${version}${extra}?deps=react@${REACT_VERSION}`;
const importUrl = (pkg: string, version: string, path = '') => {
let params = `?deps=react@${REACT_VERSION},react-dom@${REACT_VERSION}`;
if (DEVELOPMENT_BUILDS) params += '&dev';
if (path.includes('?')) params = params.replace('?', '&');

return `https://esm.sh/${ESM_SH_VERSION}/${pkg}@${version}${path}${params}`;
};

const handlePackageExceptions = (
pkg: string,
version: string,
importMap: Map<string, string>
) => {
if (pkg === 'react')
importMap.set(
`${pkg}/jsx-runtime`,
importUrl(pkg, version, '/jsx-runtime')
);
else if (pkg === 'react-syntax-highlighter') {
if (pkg === 'react-syntax-highlighter') {
importMap.set(
`${pkg}/dist/cjs/styles/prism/vs-dark.js`,
importUrl(pkg, version, '/dist/esm/styles/prism/vs-dark.js')
Expand Down
2 changes: 1 addition & 1 deletion packages/create-spectacle/src/templates/one-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const onePageTemplate = ({
<script type="module">
import htm from 'htm';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactDOM from 'react-dom/client';
import {
FlexBox,
Heading,
Expand Down
Loading