const buildJavascriptBody = ({ id, html, js, css, version, hyperformulaVersion, sandbox, lang }) => {
if (sandbox === 'stackblitz') {
return {
files: {
'package.json': {
content: `{
"name": "handsontable",
"version": "1.0.0",
"description": "",
"dependencies": {
"hyperformula": "${hyperformulaVersion}",
"handsontable": "${version}"
}
}`
},
'index.html': {
content: `
Handsontable
${html || ``}
`
},
'styles.css': {
content: css
},
[`index.${lang}`]: {
content: `import './styles.css'
${js}`
},
}
};
}
return {
files: {
'package.json': {
content: `{
"name": "handsontable",
"version": "1.0.0",
"description": "",
"main": "index.html",
"scripts": {
"start": "parcel --no-source-maps index.html --open",
"build": "parcel build index.html"
},
"dependencies": {
"hyperformula": "${hyperformulaVersion}",
"handsontable": "${version}"
},
"devDependencies": {
"@babel/core": "7.2.0",
"parcel-bundler": "^1.6.1"
}
}`
},
'index.html': {
content: `
Handsontable
${js.includes('import { HyperFormula } from \'hyperformula\';')
? ''
: ''}
${html || ``}
`
},
'src/styles.css': {
content: css
},
[`src/index.${lang}`]: {
content: js.replace('import { HyperFormula } from \'hyperformula\';', '')
}
}
};
};
module.exports = { buildJavascriptBody };