revert quotes

pull/8504/head
gtmnayan 3 years ago
parent df6839559d
commit 81af2128fe

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

Loading…
Cancel
Save