8000 Unvendor toml package (#1263) · Conan520/pyscript@84e4e36 · GitHub
[go: up one dir, main page]

Skip to content

Commit 84e4e36

Browse files
authored
Unvendor toml package (pyscript#1263)
* Unvendor toml package * Try @iarna/toml instead * Fix import * Use @ltd/j-toml * Update test * Use toml-j0.4 * Fix toml import
1 parent 41a8d80 commit 84e4e36

File tree

5 files changed

+23
-1795
lines changed

5 files changed

+23
-1795
lines changed

pyscriptjs/package-lock.json

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyscriptjs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"@codemirror/state": "6.1.2",
5050
"@codemirror/theme-one-dark": "6.1.0",
5151
"@codemirror/view": "6.3.0",
52-
"codemirror": "6.0.1"
52+
"codemirror": "6.0.1",
53+
"toml-j0.4": "^1.1.1"
5354
}
5455
}

pyscriptjs/rollup.config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import commonjs from '@rollup/plugin-commonjs';
22
import resolve from '@rollup/plugin-node-resolve';
33
import { terser } from 'rollup-plugin-terser';
4-
import legacy from '@rollup/plugin-legacy';
54
import typescript from '@rollup/plugin-typescript';
65
import css from 'rollup-plugin-css-only';
76
import serve from 'rollup-plugin-serve';
@@ -46,7 +45,6 @@ export default {
4645
string({
4746
include: './src/**/*.py',
4847
}),
49-
legacy({ 'src/toml.js': 'toml' }),
5048
resolve({
5149
browser: true,
5250
}),

pyscriptjs/src/pyconfig.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import toml from '../src/toml';
1+
import toml from 'toml-j0.4';
22
import { getLogger } from './logger';
33
import { version } from './version';
44
import { getAttribute, readTextFromPath, htmlDecode, createDeprecationWarning } from './utils';
@@ -145,17 +145,18 @@ function mergeConfig(inlineConfig: AppConfig, externalConfig: AppConfig): AppCon
145145

146146
function parseConfig(configText: string, configType = 'toml') {
147147
if (configType === 'toml') {
148+
// TOML parser is soft and can parse even JSON strings, this additional check prevents it.
149+
if (configText.trim()[0] === '{') {
150+
throw new UserError(
151+
ErrorCode.BAD_CONFIG,
152+
`The config supplied: ${configText} is an invalid TOML and cannot be parsed`,
153+
);
154+
}
148155
try {
149-
// TOML parser is soft and can parse even JSON strings, this additional check prevents it.
150-
if (configText.trim()[0] === '{') {
151-
throw new UserError(
152-
ErrorCode.BAD_CONFIG,
153-
`The config supplied: ${configText} is an invalid TOML and cannot be parsed`,
154-
);
155-
}
156156
return toml.parse(configText);
157157
} catch (err) {
158158
const errMessage: string = err.toString();
159+
159160
throw new UserError(
160161
ErrorCode.BAD_CONFIG,
161162
`The config supplied: ${configText} is an invalid TOML and cannot be parsed: ${errMessage}`,

0 commit comments

Comments
 (0)
0