chore: unbundled esm (#8613)

- remove esm bundle step
- introduce generated version.js because we can no longer use replace because we don't bundle esm
- remove register hook, cjs compiler output and cjs runtime
- keep umd compiler version for prettier/eslint/browser but without sourcemaps
- move devdependencies to dependencies where necessary
- various cleanup

---------

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: gtmnayan <50981692+gtm-nayan@users.noreply.github.com>
pull/8628/head
Simon H 1 year ago committed by GitHub
parent d658e7036e
commit a40af4dd11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

20
.gitignore vendored

@ -4,17 +4,17 @@
node_modules
*.map
/src/compiler/compile/internal_exports.js
/src/shared/version.js
/compiler.d.ts
/compiler.*js
/index.*js
/ssr.*js
/action
/internal
/store
/easing
/motion
/transition
/animate
/compiler.cjs
/index.d.ts
/action.d.ts
/internal.d.ts
/store.d.ts
/easing.d.ts
/motion.d.ts
/transition.d.ts
/animate.d.ts
/scratch/
/test/*/samples/_
/test/runtime/shards

@ -5,6 +5,7 @@
/site
!/src
src/compiler/compile/internal_exports.js
src/shared/version.js
!/test
/test/**/*.svelte
/test/**/_expected*
@ -12,4 +13,5 @@ src/compiler/compile/internal_exports.js
/test/**/expected*
/test/**/_output
/types
!rollup.config.js
!vitest.config.js

@ -7,6 +7,7 @@
* **breaking** Bundlers must specify the `browser` condition when building a frontend bundle for the browser ([#8516](https://github.com/sveltejs/svelte/pull/8516))
* **breaking** Minimum supported vite-plugin-svelte version is now 2.1.1. SvelteKit users can upgrade to 1.15.9 or newer to ensure a compatible version ([#8516](https://github.com/sveltejs/svelte/pull/8516))
* **breaking** Minimum supported TypeScript version is now TypeScript 5 (it will likely work with lower versions, but we make no guarantees about that) ([#8488](https://github.com/sveltejs/svelte/pull/8488))
* **breaking** Remove `svelte/register` hook, CJS runtime version and CJS compiler output ([#8613](https://github.com/sveltejs/svelte/pull/8613))
* **breaking** Stricter types for `createEventDispatcher` (see PR for migration instructions) ([#7224](https://github.com/sveltejs/svelte/pull/7224))
* **breaking** Stricter types for `Action` and `ActionReturn` (see PR for migration instructions) ([#7224](https://github.com/sveltejs/svelte/pull/7224))
* **breaking** Stricter types for `onMount` - now throws a type error when returning a function asynchronously to catch potential mistakes around callback functions (see PR for migration instructions) ([#8136](https://github.com/sveltejs/svelte/pull/8136))

@ -1,4 +0,0 @@
if (!process.env.PUBLISH) {
console.error('npm publish must be run with the PUBLISH environment variable set');
process.exit(1);
}

@ -1,3 +0,0 @@
{
"types": "./index.d.ts"
}

@ -3,22 +3,22 @@
"version": "4.0.0-next.0",
"description": "Cybernetically enhanced web apps",
"type": "module",
"module": "index.mjs",
"main": "index",
"module": "src/runtime/index.js",
"main": "src/runtime/index.js",
"files": [
"src",
"types",
"compiler.*",
"register.js",
"index.*",
"ssr.*",
"internal",
"store",
"animate",
"transition",
"easing",
"motion",
"action",
"elements",
"index.d.ts",
"internal.d.ts",
"store.d.ts",
"animate.d.ts",
"transition.d.ts",
"easing.d.ts",
"motion.d.ts",
"action.d.ts",
"elements.d.ts",
"README.md"
],
"exports": {
@ -26,55 +26,44 @@
".": {
"types": "./types/runtime/index.d.ts",
"browser": {
"import": "./index.mjs",
"require": "./index.js"
"import": "./src/runtime/index.js"
},
"import": "./ssr.mjs",
"require": "./ssr.js"
"import": "./src/runtime/ssr.js"
},
"./compiler": {
"types": "./types/compiler/index.d.ts",
"import": "./compiler.mjs",
"require": "./compiler.js"
"import": "./src/compiler/index.js",
"require": "./compiler.cjs"
},
"./action": {
"types": "./types/runtime/action/index.d.ts"
},
"./animate": {
"types": "./types/runtime/animate/index.d.ts",
"import": "./animate/index.mjs",
"require": "./animate/index.js"
"import": "./src/runtime/animate/index.js"
},
"./easing": {
"types": "./types/runtime/easing/index.d.ts",
"import": "./easing/index.mjs",
"require": "./easing/index.js"
"import": "./src/runtime/easing/index.js"
},
"./internal": {
"types": "./types/runtime/internal/index.d.ts",
"import": "./internal/index.mjs",
"require": "./internal/index.js"
"import": "./src/runtime/internal/index.js"
},
"./motion": {
"types": "./types/runtime/motion/index.d.ts",
"import": "./motion/index.mjs",
"require": "./motion/index.js"
},
"./register": {
"require": "./register.js"
"import": "./src/runtime/motion/index.js"
},
"./store": {
"types": "./types/runtime/store/index.d.ts",
"import": "./store/index.mjs",
"require": "./store/index.js"
"import": "./src/runtime/store/index.js"
},
"./transition": {
"types": "./types/runtime/transition/index.d.ts",
"import": "./transition/index.mjs",
"require": "./transition/index.js"
"import": "./src/runtime/transition/index.js"
},
"./elements": {
"types": "./elements/index.d.ts"
"types": "./elements.d.ts"
}
},
"engines": {
@ -88,9 +77,9 @@
"build": "rollup -c && npm run tsd",
"prepare": "npm run build",
"dev": "rollup -cw",
"posttest": "agadoo internal/index.mjs",
"prepublishOnly": "node check_publish_env.js && npm run lint && npm run build && npm test",
"tsd": "node ./generate-types.mjs",
"posttest": "agadoo src/internal/index.js",
"prepublishOnly": "npm run lint && npm run build && npm test",
"tsd": "node ./generate-types.js",
"lint": "eslint \"{src,test}/**/*.{ts,js}\" --cache"
},
"repository": {
@ -109,50 +98,45 @@
"url": "https://github.com/sveltejs/svelte/issues"
},
"homepage": "https://svelte.dev",
"devDependencies": {
"dependencies": {
"@ampproject/remapping": "^2.2.1",
"@jridgewell/sourcemap-codec": "^1.4.15",
"acorn": "^8.8.2",
"aria-query": "^5.1.3",
"axobject-query": "^3.1.1",
"code-red": "^1.0.0",
"css-tree": "^2.3.1",
"estree-walker": "^3.0.3",
"is-reference": "^3.0.1",
"locate-character": "^2.0.5",
"magic-string": "^0.30.0",
"periscopic": "^3.1.0"
},
"devDependencies": {
"@playwright/test": "^1.33.0",
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-sucrase": "^5.0.1",
"@rollup/plugin-typescript": "^11.1.0",
"@rollup/plugin-virtual": "^3.0.1",
"@sveltejs/eslint-config": "^6.0.1",
"@types/aria-query": "^5.0.1",
"@types/estree": "^1.0.0",
"@types/mocha": "^10.0.1",
"@types/node": "^14.14.31",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"acorn": "^8.8.2",
"agadoo": "^3.0.0",
"aria-query": "^5.1.3",
"axobject-query": "^3.1.1",
"code-red": "^1.0.0",
"css-tree": "^2.3.1",
"esbuild": "^0.17.19",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-svelte": "^2.28.0",
"eslint-plugin-unicorn": "^47.0.0",
"estree-walker": "^3.0.3",
"happy-dom": "^9.18.3",
"is-reference": "^3.0.1",
"jsdom": "^21.1.1",
"kleur": "^4.1.5",
"locate-character": "^2.0.5",
"magic-string": "^0.30.0",
"periscopic": "^3.1.0",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.0",
"rollup": "^3.20.2",
"rollup-plugin-dts": "^5.3.0",
"source-map": "^0.7.4",
"tiny-glob": "^0.2.9",
"tslib": "^2.5.0",
"typescript": "^5.0.4",
"util": "^0.12.5",
"vitest": "^0.31.1"

File diff suppressed because it is too large Load Diff

@ -1,56 +0,0 @@
const fs = require('fs');
const path = require('path');
const { compile } = require('./compiler.js');
const extensions = ['.svelte', '.html'];
let compileOptions = {};
function capitalise(name) {
return name[0].toUpperCase() + name.slice(1);
}
function register(options = {}) {
if (options.extensions) {
extensions.forEach(deregisterExtension);
options.extensions.forEach(registerExtension);
}
compileOptions = Object.assign({}, options);
delete compileOptions.extensions;
}
function deregisterExtension(extension) {
delete require.extensions[extension];
}
function registerExtension(extension) {
require.extensions[extension] = function(module, filename) {
const name = path.parse(filename).name
.replace(/^\d/, '_$&')
.replace(/[^a-zA-Z0-9_$]/g, '');
const options = Object.assign({}, compileOptions, {
filename,
name: capitalise(name),
generate: 'ssr',
format: 'cjs'
});
const { js, warnings } = compile(fs.readFileSync(filename, 'utf-8'), options);
if (options.dev) {
warnings.forEach(warning => {
console.warn(`\nSvelte Warning in ${warning.filename}:`);
console.warn(warning.message);
console.warn(warning.frame);
})
}
return module._compile(js.code, filename);
};
}
registerExtension('.svelte');
registerExtension('.html');
module.exports = register;

@ -0,0 +1,82 @@
import fs from 'node:fs';
import { createRequire } from 'node:module';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
const require = createRequire(import.meta.url);
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
// Create auto-generated .js files
fs.writeFileSync(
'./src/shared/version.js',
`/** @type {string} */\nexport const VERSION = '${pkg.version}';`
);
const internal = await import('./src/runtime/internal/index.js');
fs.writeFileSync(
'src/compiler/compile/internal_exports.js',
`// This file is automatically generated\n` +
`export default new Set(${JSON.stringify(Object.keys(internal))});`
);
// Generate d.ts files for runtime entrypoints so that TS can find it also without `"moduleResolution": "bundler"`
fs.readdirSync('src/runtime', { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.forEach((dirent) =>
fs.writeFileSync(
`${dirent.name}.d.ts`,
`export * from './types/runtime/${dirent.name}/index.js';`
)
);
fs.writeFileSync('./index.d.ts', `export * from './types/runtime/index.js';`);
fs.writeFileSync(
'./compiler.d.ts',
`export { compile, parse, preprocess, walk, VERSION } from './types/compiler/index.js';`
);
/**
* @type {import("rollup").RollupOptions[]}
*/
export default [
// Generate UMD build of the compiler so that Eslint/Prettier (which need CJS) and REPL (which needs UMD because browser) can use it
{
input: 'src/compiler/index.js',
plugins: [
replace({
preventAssignment: true,
values: {
'process.env.NODE_DEBUG': false // appears inside the util package
}
}),
{
resolveId(id) {
// util is a built-in module in Node.js, but we want a self-contained compiler bundle
// that also works in the browser, so we load its polyfill instead
if (id === 'util') {
return require.resolve('./node_modules/util'); // just 'utils' would resolve this to the built-in module
}
// Must import from the `css-tree` browser bundled distribution due to `createRequire` usage if importing from css-tree directly
if (id === 'css-tree') {
return require.resolve('./node_modules/css-tree/dist/csstree.esm.js');
}
}
},
resolve(),
commonjs({
include: ['node_modules/**']
}),
json()
],
output: {
file: 'compiler.cjs',
format: 'umd',
name: 'svelte',
sourcemap: false
},
external: []
}
];

@ -1,150 +0,0 @@
import fs from 'node:fs';
import { createRequire } from 'node:module';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import sucrase from '@rollup/plugin-sucrase';
import typescript from '@rollup/plugin-typescript';
const require = createRequire(import.meta.url);
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
const is_publish = !!process.env.PUBLISH;
const ts_plugin = is_publish
? typescript({
typescript: require('typescript'),
paths: {
'svelte/*': ['./src/runtime/*']
}
})
: sucrase({
transforms: ['typescript']
});
fs.writeFileSync(
`./compiler.d.ts`,
`export { compile, parse, preprocess, walk, VERSION } from './types/compiler/index.js';`
);
const runtime_entrypoints = Object.fromEntries(
fs
.readdirSync('src/runtime', { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => [dirent.name, `src/runtime/${dirent.name}/index.js`])
);
/**
* @type {import("rollup").RollupOptions[]}
*/
export default [
{
input: {
...runtime_entrypoints,
index: 'src/runtime/index.js',
ssr: 'src/runtime/ssr.js'
},
output: ['es', 'cjs'].map(
/** @returns {import('rollup').OutputOptions} */
(format) => {
const ext = format === 'es' ? 'mjs' : 'js';
return {
entryFileNames: (entry) => {
if (entry.isEntry) {
if (entry.name === 'index') return `index.${ext}`;
else if (entry.name === 'ssr') return `ssr.${ext}`;
return `${entry.name}/index.${ext}`;
}
},
chunkFileNames: `internal/[name]-[hash].${ext}`,
format,
minifyInternalExports: false,
dir: '.',
};
}
),
plugins: [
replace({
preventAssignment: true,
values: {
__VERSION__: pkg.version,
},
}),
ts_plugin,
{
writeBundle(options, bundle) {
if (options.format !== 'es') return;
for (const entry of Object.values(bundle)) {
const dir = entry.name;
if (!entry.isEntry || !runtime_entrypoints[dir]) continue;
if (dir === 'internal') {
const mod = bundle[`internal/index.mjs`];
if (mod) {
fs.writeFileSync(
'src/compiler/compile/internal_exports.js',
`// This file is automatically generated\n` +
`export default new Set(${JSON.stringify(mod.exports)});`
);
}
}
fs.writeFileSync(
`${dir}/index.d.ts`,
`export * from '../types/runtime/${dir}/index.js';`
);
}
}
}
]
},
/* compiler.js */
{
input: 'src/compiler/index.js',
plugins: [
replace({
preventAssignment: true,
values: {
__VERSION__: pkg.version,
'process.env.NODE_DEBUG': false // appears inside the util package
},
}),
{
resolveId(id) {
// util is a built-in module in Node.js, but we want a self-contained compiler bundle
// that also works in the browser, so we load its polyfill instead
if (id === 'util') {
return require.resolve('./node_modules/util'); // just 'utils' would resolve this to the built-in module
}
},
},
resolve(),
commonjs({
include: ['node_modules/**']
}),
json(),
ts_plugin
],
output: [
{
file: 'compiler.js',
format: is_publish ? 'umd' : 'cjs',
name: 'svelte',
sourcemap: true,
},
{
file: 'compiler.mjs',
format: 'esm',
name: 'svelte',
sourcemap: true,
}
],
external: is_publish
? []
: (id) =>
id === 'acorn' || id === 'magic-string' || id.startsWith('css-tree')
}
];

@ -1,7 +1,7 @@
/** ----------------------------------------------------------------------
This script gets a list of global objects/functions of browser.
This process is simple for now, so it is handled without AST parser.
Please run `node scripts/globals-extractor.mjs` at the project root.
Please run `node scripts/globals-extractor.js` at the project root.
see: https://github.com/microsoft/TypeScript/tree/main/lib
---------------------------------------------------------------------- */
@ -68,7 +68,7 @@ const build_output = (functions) => {
const sorted = Array.from(new Set(functions.sort()));
return `\
/** ----------------------------------------------------------------------
This file is automatically generated by \`scripts/globals-extractor.mjs\`.
This file is automatically generated by \`scripts/globals-extractor.js\`.
Generated At: ${new Date().toISOString()}
---------------------------------------------------------------------- */

@ -985,6 +985,8 @@ You can explore the various eases using the [ease visualiser](/examples/easing)
### `svelte/register`
> This API is removed in Svelte 4. `require` hooks are deprecated and current Node versions understand ESM. Use a bundler like Vite or our full-stack framework [SvelteKit](https://kit.svelte.dev) instead to create JavaScript modules from Svelte components.
To render Svelte components in Node.js without bundling, use `require('svelte/register')`. After that, you can use `require` to include any `.svelte` file.
```js

@ -39,7 +39,6 @@ The following options can be passed to the compiler. None are required:
| --- | --- | --- |
| `filename` | string | `null`
| `name` | string | `"Component"`
| `format` | `"esm"` or `"cjs"` | `"esm"`
| `generate` | `"dom"` or `"ssr"` or `false` | `"dom"`
| `errorMode` | `"throw"` or `"warn"` | `"throw"`
| `varsReport` | `"strict"` or `"full"` or `false` | `"strict"`
@ -62,7 +61,6 @@ The following options can be passed to the compiler. None are required:
| --- | --- | --- |
| `filename` | `null` | `string` used for debugging hints and sourcemaps. Your bundler plugin will set it automatically.
| `name` | `"Component"` | `string` that sets the name of the resulting JavaScript class (though the compiler will rename it if it would otherwise conflict with other variables in scope). It will normally be inferred from `filename`.
| `format` | `"esm"` | If `"esm"`, creates a JavaScript module (with `import` and `export`). If `"cjs"`, creates a CommonJS module (with `require` and `module.exports`), which is useful in some server-side rendering situations or for testing.
| `generate` | `"dom"` | If `"dom"`, Svelte emits a JavaScript class for mounting to the DOM. If `"ssr"`, Svelte emits an object with a `render` method suitable for server-side rendering. If `false`, no JavaScript or CSS is returned; just metadata.
| `errorMode` | `"throw"` | If `"throw"`, Svelte throws when a compilation error occurred. If `"warn"`, Svelte will treat errors as warnings and add them to the warning report.
| `varsReport` | `"strict"` | If `"strict"`, Svelte returns a variables report with only variables that are not globals nor internals. If `"full"`, Svelte returns a variables report with all detected variables. If `false`, no variables report is returned.

@ -28,6 +28,7 @@ import {
extract_svelte_ignore_from_comments
} from '../utils/extract_svelte_ignore.js';
import check_enable_sourcemap from './utils/check_enable_sourcemap.js';
import { VERSION } from '../../shared/version.js';
const regex_leading_directory_separator = /^[/\\]/;
const regex_starts_with_term_export = /^Export/;
@ -319,8 +320,7 @@ export default class Component {
let css = null;
if (result) {
const { compile_options, name } = this;
const { format = 'esm' } = compile_options;
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'__VERSION__'}`;
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${VERSION}`;
/** @type {any} */
const program = { type: 'Program', body: result.js };
@ -387,7 +387,6 @@ export default class Component {
);
create_module(
program,
format,
name,
banner,
compile_options.sveltePath,

@ -1,10 +1,7 @@
import list from '../utils/list.js';
import { b, x } from 'code-red';
const wrappers = { esm, cjs };
import { b } from 'code-red';
/**
* @param {any} program
* @param {import('../interfaces.js').ModuleFormat} format
* @param {import('estree').Identifier} name
* @param {string} banner
* @param {any} sveltePath
@ -16,7 +13,6 @@ const wrappers = { esm, cjs };
*/
export default function create_module(
program,
format,
name,
banner,
sveltePath = 'svelte',
@ -39,11 +35,7 @@ export default function create_module(
* @param {any} b
*/ (a, b) => (a.name < b.name ? -1 : 1)
);
const formatter = wrappers[format];
if (!formatter) {
throw new Error(`options.format is invalid (must be ${list(Object.keys(wrappers))})`);
}
return formatter(
return esm(
program,
name,
banner,
@ -174,124 +166,7 @@ function esm(
}
/**
* @param {any} program
* @param {import('estree').Identifier} name
* @param {string} banner
* @param {string} sveltePath
* @param {string} internal_path
* @param {Array<{ name: string; alias: import('estree').Identifier }>} helpers
* @param {Array<{ name: string; alias: import('estree').Identifier }>} globals
* @param {import('estree').ImportDeclaration[]} imports
* @param {Export[]} module_exports
* @param {import('estree').ExportNamedDeclaration[]} exports_from
*/
function cjs(
program,
name,
banner,
sveltePath,
internal_path,
helpers,
globals,
imports,
module_exports,
exports_from
) {
const internal_requires = {
type: 'VariableDeclaration',
kind: 'const',
declarations: [
{
type: 'VariableDeclarator',
id: {
type: 'ObjectPattern',
properties: helpers.map(
/** @param {any} h */ (h) => ({
type: 'Property',
method: false,
shorthand: false,
computed: false,
key: { type: 'Identifier', name: h.name },
value: h.alias,
kind: 'init'
})
)
},
init: x`require("${internal_path}")`
}
]
};
const internal_globals = get_internal_globals(globals, helpers);
const user_requires = imports.map(
/** @param {any} node */ (node) => {
const init = x`require("${edit_source(node.source.value, sveltePath)}")`;
if (node.specifiers.length === 0) {
return b`${init};`;
}
return {
type: 'VariableDeclaration',
kind: 'const',
declarations: [
{
type: 'VariableDeclarator',
id:
node.specifiers[0].type === 'ImportNamespaceSpecifier'
? { type: 'Identifier', name: node.specifiers[0].local.name }
: {
type: 'ObjectPattern',
properties: node.specifiers.map(
/** @param {any} s */ (s) => ({
type: 'Property',
method: false,
shorthand: false,
computed: false,
key:
s.type === 'ImportSpecifier'
? s.imported
: { type: 'Identifier', name: 'default' },
value: s.local,
kind: 'init'
})
)
},
init
}
]
};
}
);
const exports = module_exports.map(
/** @param {any} x */
(x) =>
b`exports.${{ type: 'Identifier', name: x.as }} = ${{ type: 'Identifier', name: x.name }};`
);
const user_exports_from = exports_from.map(
/** @param {any} node */ (node) => {
const init = x`require("${edit_source(node.source.value, sveltePath)}")`;
return node.specifiers.map(
/** @param {any} specifier */ (specifier) => {
return b`exports.${specifier.exported} = ${init}.${specifier.local};`;
}
);
}
);
program.body = b`
/* ${banner} */
"use strict";
${internal_requires}
${internal_globals}
${user_requires}
${user_exports_from}
${program.body}
exports.default = ${name};
${exports}
`;
}
/** @typedef {Object} Export
* @typedef {Object} Export
* @property {string} name
* @property {string} as
*/

@ -2,6 +2,4 @@ export { default as compile } from './compile/index.js';
export { default as parse } from './parse/index.js';
export { default as preprocess } from './preprocess/index.js';
export { walk } from 'estree-walker';
/** @type {string} */
export const VERSION = '__VERSION__';
export { VERSION } from '../shared/version.js';

@ -159,8 +159,6 @@ export interface Warning {
toString: () => string;
}
export type ModuleFormat = 'esm' | 'cjs';
export type EnableSourcemap = boolean | { js: boolean; css: boolean };
export type CssHashGetter = (args: {
@ -171,7 +169,6 @@ export type CssHashGetter = (args: {
}) => string;
export interface CompileOptions {
format?: ModuleFormat;
name?: string;
filename?: string;
generate?: 'dom' | 'ssr' | false;

@ -1,7 +1,4 @@
// @ts-nocheck
// Note: Must import from the `css-tree` browser bundled distribution due to `createRequire` usage if importing from
// `css-tree` Node module directly. This allows the production build of Svelte to work correctly.
// import { fork } from '../../../../../node_modules/css-tree/dist/csstree.esm.js';
import { fork } from 'css-tree';
import * as node from './node/index.js';

@ -1,2 +1,2 @@
export type { CompileOptions, ModuleFormat, EnableSourcemap, CssHashGetter } from './interfaces';
export type { CompileOptions, EnableSourcemap, CssHashGetter } from './interfaces';
export type * from './preprocess/public.js';

@ -1,6 +1,6 @@
/** ----------------------------------------------------------------------
This file is automatically generated by `scripts/globals-extractor.mjs`.
Generated At: 2023-05-11T15:31:28.406Z
This file is automatically generated by `scripts/globals-extractor.js`.
Generated At: 2023-05-24T13:16:20.777Z
---------------------------------------------------------------------- */
export default new Set([

@ -10,6 +10,7 @@ import {
} from './dom.js';
import { SvelteComponent } from './Component.js';
import { is_void } from '../../shared/utils/names.js';
import { VERSION } from '../../shared/version.js';
import { contenteditable_truthy_values } from './utils.js';
/**
@ -19,9 +20,7 @@ import { contenteditable_truthy_values } from './utils.js';
* @returns {void}
*/
export function dispatch_dev(type, detail) {
document.dispatchEvent(
custom_event(type, { version: '__VERSION__', ...detail }, { bubbles: true })
);
document.dispatchEvent(custom_event(type, { version: VERSION, ...detail }, { bubbles: true }));
}
/**

@ -1,9 +1,9 @@
import { identity as linear, is_function, noop, run_all } from './utils.js';
import { now } from './environment';
import { loop } from './loop';
import { create_rule, delete_rule } from './style_manager';
import { custom_event } from './dom';
import { add_render_callback } from './scheduler';
import { now } from './environment.js';
import { loop } from './loop.js';
import { create_rule, delete_rule } from './style_manager.js';
import { custom_event } from './dom.js';
import { add_render_callback } from './scheduler.js';
/**
* @type {Promise<void> | null}

@ -21,7 +21,6 @@ describe('compiler-errors', () => {
const cwd = path.resolve(`${__dirname}/samples/${dir}`);
const compileOptions = Object.assign({}, config.compileOptions || {}, {
format: 'cjs',
immutable: config.immutable,
accessors: 'accessors' in config ? config.accessors : true,
generate: 'dom'

@ -37,7 +37,10 @@ describe('js-output', () => {
actual = svelte
.compile(input, options)
.js.code.replace(/generated by Svelte v__VERSION__/, 'generated by Svelte vX.Y.Z');
.js.code.replace(
/generated by Svelte v\d+\.\d+\.\d+(-\w+\.\d+)?/,
'generated by Svelte vX.Y.Z'
);
} catch (err) {
console.log(err.frame);
throw err;

@ -1,6 +0,0 @@
export default {
options: {
accessors: true,
format: 'cjs'
}
};

@ -1,36 +0,0 @@
/* generated by Svelte vX.Y.Z */
"use strict";
const { SvelteComponent, init, safe_not_equal } = require("svelte/internal");
const { f: f_1, g: g_1 } = require("./d");
const { h: h_1 } = require("./e");
const { i: j } = require("./f");
exports.e = require("./c").d;
exports.c = require("./b").c;
exports.a = require("./a").a;
exports.b = require("./a").b;
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, null, null, safe_not_equal, {});
}
get f() {
return f_1;
}
get g() {
return g_1;
}
get h() {
return h_1;
}
get j() {
return j;
}
}
exports.default = Component;

@ -1,11 +0,0 @@
<script context="module">
export { a, b } from './a';
export { c } from './b';
export { d as e } from './c';
</script>
<script>
export { f, g } from './d';
export { h } from './e';
export { i as j } from './f';
</script>
Loading…
Cancel
Save