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
284 changes: 149 additions & 135 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@
"sass-loader": "^11.0.1",
"semver": "^7.3.2",
"style-loader": "^2.0.0",
"svelte": "^4.2.8",
"svelte-loader": "^3.1.9",
"svelte": "^5.17.4",
"svelte-loader": "^3.2.4",
"svelte-preprocess": "^5.1.1",
"tcp-ping-sync": "^1.0.0",
"ts-loader": "^9.5.1",
"typescript": "^5.3.2",
"update-notifier": "^6.0.2",
"webpack": "^5.33.2",
Expand Down
74 changes: 49 additions & 25 deletions src/config/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,7 @@ const PROJECT_TYPES_CONFIG = {
*/
svelte: config => {
config.resolve = {
// Make sure that only one copy of the Svelte runtime is bundled in the app
alias: {
svelte: resolve('node_modules', 'svelte/src/runtime')
},
// Recognise .svelte files
extensions: [...config.resolve.extensions, '.svelte'],
// When using Svelte components installed from npm, use the original component
// source code, rather than consuming the already-compiled version
mainFields: ['svelte', 'browser', 'module', 'main'],
conditionNames: ['svelte', 'browser', 'import']
};
Expand All @@ -62,31 +55,62 @@ const PROJECT_TYPES_CONFIG = {

include.push(/(node_modules\/svelte)/);

config.module.rules.push({
test: /\.svelte$/,
include,
use: [
// options from https://github.com/sveltejs/svelte-loader
config.module.rules.push(
...[
{
loader,
options
test: /\.svelte\.ts$/,
use: [
{
loader,
options
},
{ loader: require.resolve('ts-loader'), options: { transpileOnly: true } },
{
loader: require.resolve('svelte-loader'),
options: {
dev: config.mode === 'development',
emitCss: extractCSS,
preprocess: sveltePreprocess()
}
}
]
},
{
loader: require.resolve('svelte-loader'),
test: /(?<!\.svelte)\.ts$/,
loader: require.resolve('ts-loader'),
options: {
dev: config.mode === 'development',
emitCss: extractCSS,
preprocess: sveltePreprocess()
transpileOnly: true // you should use svelte-check for type checking
}
},
{
// Svelte 5+:
test: /\.(svelte|svelte\.js)$/,
include,
use: [
{
loader,
options
},
{
loader: require.resolve('svelte-loader'),
options: {
dev: config.mode === 'development',
emitCss: extractCSS,
preprocess: sveltePreprocess()
}
}
]
},
{
// required to prevent errors from Svelte on Webpack 5+, omit on Webpack 4
test: /node_modules\/svelte\/.*\.mjs$/,
resolve: {
fullySpecified: false
}
}
]
});
// Required to prevent errors from Svelte on Webpack 5+
config.module.rules.push({
test: /node_modules\/svelte\/.*\.mjs$/,
resolve: {
fullySpecified: false
}
});
);

return config;
}
Expand Down
2 changes: 1 addition & 1 deletion src/generators/project/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ Shorthand examples (assuming xyz is your project name):
break;
case 'svelte':
devDependencies.push('@testing-library/svelte');
dependencies.push('svelte@4');
dependencies.push('svelte@5');
break;
default:
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h<% if (isTS) { %>, FunctionalComponent<% } %> } from 'preact';
import { h<% if (isTS) { %>, type FunctionalComponent<% } %> } from 'preact';
import Worm from '../Worm';
import styles from './styles.scss';
<% if (isTS) { %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h<% if (isTS) { %>, FunctionalComponent<% } %> } from 'preact';
import { h<% if (isTS) { %>, type FunctionalComponent<% } %> } from 'preact';
import { useEffect } from 'preact/hooks';
import styles from './styles.scss';
<% if (isTS) { %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { h<% if (isTS) { %>, FunctionalComponent<% } %> } from 'preact';
import { h<% if (isTS) { %>, type FunctionalComponent<% } %> } from 'preact';
import styles from './styles.scss';
import worm from './worm.svg';

Expand Down
2 changes: 1 addition & 1 deletion src/generators/project/templates/react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import acto from '@abcnews/alternating-case-to-object';
import { <% if (isOdyssey) { %>whenOdysseyLoaded<% } else { %>whenDOMReady<% } %> } from '@abcnews/env-utils';
import { getMountValue, selectMounts } from '@abcnews/mount-utils';
import React from 'react';
import { createRoot<% if (isTS) { %>, Root<% } %> } from 'react-dom/client';
import { createRoot<% if (isTS) { %>, type Root<% } %> } from 'react-dom/client';
import App from './components/App';<% if (isTS) { %>
import type { AppProps } from './components/App';<% } %>

Expand Down
4 changes: 3 additions & 1 deletion src/generators/project/templates/svelte/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { <% if (isOdyssey) { %>whenOdysseyLoaded<% } else { %>whenDOMReady<% } %
import { getMountValue, selectMounts } from '@abcnews/mount-utils';<% if (isTS) { %>
import type { Mount } from '@abcnews/mount-utils';<% } %>
import App from './components/App/App.svelte';
import { mount } from 'svelte';

let appMountEl<% if (isTS) { %>: Mount<% } %>;
let appProps;
Expand All @@ -12,7 +13,8 @@ let appProps;

if (appMountEl) {
appProps = acto(getMountValue(appMountEl));
new App({

mount(App, {
target: appMountEl,
props: appProps
});
Expand Down
2 changes: 1 addition & 1 deletion ts/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"verbatimModuleSyntax": false,
"verbatimModuleSyntax": true,
"resolveJsonModule": true,
"isolatedModules": true,
"strictNullChecks": true
Expand Down
Loading