Skip to content

Fix ESM #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
43 changes: 19 additions & 24 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import { compile } from 'svelte/compiler';
import { compile } from 'svelte/compiler';
import chokidar from 'chokidar';
import esbuild from 'esbuild';
import { readdirSync, statSync, existsSync, writeFileSync, readFileSync } from 'fs';
import { join, basename, resolve, dirname, relative } from 'path';
import { fileURLToPath } from 'url';
import {readdirSync, statSync, existsSync, writeFileSync, readFileSync} from 'fs';
import {join, basename, resolve, dirname, relative} from 'path';
import sveltePlugin from 'esbuild-svelte';
import { sum } from 'lodash-es';
import { parse, serialize } from 'parse5';
import {sum} from 'lodash-es';
import { parse } from 'parse5';
import notifier from 'node-notifier';
import svelteConfig from './svelte.config.js';
import FiveServer from 'five-server';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
import svelteConfig from './svelte.config.js';

process.on('uncaughtException', error => {
notifier.notify({
Expand Down Expand Up @@ -62,12 +58,12 @@ function findPages( dir = '.', sink = [] ) {
const _zId_prefix = `z_placeholder_${Math.floor( Math.random() * 1000000000 ).toString( 16 )}_`;
const _zReplacer = s => debug_console_log( ['z-replace:', s, `"${_zId_prefix}${Buffer.from( s ).toString( 'base64' )}"`], 2 );

const zPlaceholderReplacer = content => {
const zPlaceholderReplacer = content =>

content?.replace( /\#\{\s*\w+\s*\}/gs, _zReplacer ) // #{ key }
.replace( /\/\*\!\s*\w+\s*\*\//gs, _zReplacer ) // map /*! mapKey */
.replace( /\[\s*\/\*\s*\w+\s*\*\/\s*\]/gs, _zReplacer ) // map [/* mapKey */]
.replace( /\{\s*\/\*\s*\w+\s*\*\/\s*\}/gs, _zReplacer ); // map {/* mapKey */}
}

global.zPlaceholderReplacer = zPlaceholderReplacer;

Expand Down Expand Up @@ -106,7 +102,7 @@ function createBuilder( entryPoints ) {
bundle: true,
outdir: '.',
write: false,
plugins: [svelteJsPathResolver, sveltePlugin( svelteConfig ) ],
plugins: [svelteJsPathResolver, sveltePlugin( svelteConfig )],
incremental: !!watch,
sourcemap: false,
minify,
Expand Down Expand Up @@ -265,7 +261,7 @@ function layoutFor( path, content = {} ) {
let html = content.html || '';
const innerCss = (content.css || {}).code || '';

return serialize( tree ).
return parse.serialize( tree ).
replace( cssKEY, css + innerCss ).
replace( jsKEY, js ).
replace( appKEY, html ).
Expand Down Expand Up @@ -332,12 +328,12 @@ function layoutFor( path, content = {} ) {

function changeListener( path, stats, type, watcher ) {
switch (type) {
case 'change':
notifier.notify({
title: 'Change occurs',
message: `Change occurs in "${path}"`
});
break;
// case 'change':
// notifier.notify({
// title: 'Change occurs',
// message: `Change occurs in "${path}"`
// });
// break;
case 'add':
notifier.notify({
title: 'File added',
Expand Down Expand Up @@ -382,11 +378,10 @@ function layoutFor( path, content = {} ) {
watcherReady = true;
} )
.on( 'error', err => console.log( 'ERROR:', err ) );
};


}

serve &&
(await new FiveServer().start( {
(await new FiveServer().start( {
open: true,
workspace: __dirname,
ignore: [...ignorePath, /\.(js|ts|svelte)$/, /\_layout\.html$/],
Expand Down
32 changes: 19 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@
"serve": "node build.js --serve"
},
"devDependencies": {
"chokidar": "^3.6.0",
"esbuild": "^0.16.17",
"esbuild-svelte": "^0.7.3",
"lodash": "^4.17.21",
"node-notifier": "^10.0.1",
"parse5": "^7.1.2",
"prettier": "^2.8.8",
"svelte": "^4.0.0",
"svelte-preprocess": "^5.0.4",
"typescript": "^5.1.3"
"chokidar": "^3.5.3",
"esbuild": "0.16.17",
"esbuild-svelte": "^0.8.0",
"five-server": "^0.1.9",
"lodash": "^4.17.21",
"node-notifier": "^10.0.1",
"parse5": "^7.1.2",
"prettier": "^2.8.8",
"svelte": "^4.2.2",
"svelte-preprocess": "^5.0.4",
"typescript": "^5.2.2"
},
"prettier": {
"singleQuote": true,
Expand All @@ -29,7 +30,12 @@
"arrowParens": "avoid"
},
"dependencies": {
"five-server": "^0.3.2",
"lodash-es": "^4.17.21"
}
"five-server": "^0.3.3",
"lodash-es": "^4.17.21",
"file-selector": "^0.2.4"
Comment on lines +33 to +35
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Inconsistency in 'five-server' Versions

The package "five-server" appears in both devDependencies (version ^0.1.9) and dependencies (version ^0.3.3). This discrepancy could lead to version conflicts at runtime. Please confirm if both entries are needed or consolidate them to ensure a consistent version across the project.

},
"peerDependencies": {
"esbuild": ">=0.8 <0.18",
"esbuild-node-externals": "^1.0.0"
}
}
Loading