Skip to content
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

Custom template #854

Merged
merged 55 commits into from
Nov 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
15a182c
Custom template
CompuIves May 23, 2018
7f6cffb
Bump
CompuIves May 23, 2018
9f52253
Reset compilation when config of modules change
CompuIves May 23, 2018
0c9ee7a
Merge branch 'master' into custom-template
CompuIves Jun 11, 2018
b156ce3
Fix null sandpackconfig
CompuIves Jun 11, 2018
5ee1da7
Remove double setup
CompuIves Jun 11, 2018
977216f
Bump
CompuIves Jun 11, 2018
201fdff
Make optimization of cache optional
CompuIves Jun 11, 2018
2459c33
Bump
CompuIves Jun 11, 2018
d083cf5
Don't save cache on smoosh
CompuIves Jun 11, 2018
de0704f
BUMP
CompuIves Jun 11, 2018
a76c2c2
Add module mockgp
Jul 5, 2018
518247c
Version bump
Jul 5, 2018
fd57edb
Fix package json version resolving
Jul 5, 2018
f4b3177
Bump
Jul 5, 2018
2b042a9
mock modulke
Jul 5, 2018
ecc94e2
Fix module
Jul 5, 2018
3c57e56
Merge branch 'master' into custom-template
Jul 31, 2018
5248b33
Bump to 0.0.45
Jul 31, 2018
29641a1
Fix typing problem
Jul 31, 2018
bbb216e
Fix new build step
CompuIves Aug 3, 2018
e92ae91
Version bump
CompuIves Aug 3, 2018
d020093
Remove console.log
CompuIves Aug 3, 2018
91650b3
Bump version
CompuIves Aug 3, 2018
d1d4f28
Async file resolving
Aug 3, 2018
4b65f4f
Remote messaging system
Aug 3, 2018
976be0f
Merge branch 'master' into custom-template
Aug 3, 2018
f104183
Add remote file resolving
Aug 4, 2018
43e1d17
Bump version
Aug 6, 2018
6f50d8c
Remove comments
Aug 11, 2018
793cdfa
Allow dynamic import in ESModule dependencies
Aug 15, 2018
b12841d
Also add dynamic syntax to parser opts
Aug 16, 2018
de75d92
Fix custom template resetting for new manager
Aug 24, 2018
234f981
Bump
Aug 24, 2018
025110a
Bump
Aug 24, 2018
ec91b19
Upgrade codesandbox-api
Aug 24, 2018
9441a05
Fix typings
Aug 24, 2018
ce7287b
Fix getCodeSandboxURL
Sep 10, 2018
9707f8c
Merge branch 'master' into custom-template
Sep 10, 2018
d2d2b3a
Bump version
Sep 10, 2018
e27acc1
Fix merge conflict
Sep 10, 2018
5f8a511
Add babel transpiler
Sep 11, 2018
cd4d32b
New version bump
Sep 11, 2018
11283b6
Update locks
Sep 11, 2018
e8578a9
Publish new codesandbox-api
Sep 12, 2018
c198df4
Bump sandpack
Sep 12, 2018
be94ff5
Update codesandbox-api
Sep 12, 2018
51a44f2
Merge branch 'master' into custom-template
CompuIves Nov 15, 2018
0dd2226
Add button for disabling button
CompuIves Nov 15, 2018
de11ea2
Merge remote-tracking branch 'origin/allow-dynamic-in-dependencies' i…
CompuIves Nov 15, 2018
c35e43b
Add option to manager
CompuIves Nov 15, 2018
22caa78
Bump
CompuIves Nov 15, 2018
9644378
Rename vscode-editor
CompuIves Nov 19, 2018
b47bccd
Disable shadows altogether in SSE loading screen
CompuIves Nov 20, 2018
71ca556
Merge branch 'master' into custom-template
CompuIves Nov 23, 2018
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
2 changes: 1 addition & 1 deletion packages/app/config/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ module.exports = {
? [
new HtmlWebpackPlugin({
inject: true,
chunks: ['sandbox-startup', 'sandbox'],
chunks: ['sandbox-startup', 'vendors~sandbox', 'sandbox'],
filename: 'frame.html',
template: paths.sandboxHtml,
minify: __PROD__ && {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"cerebral": "^4.0.0",
"circular-json": "^0.4.0",
"codemirror": "^5.27.4",
"codesandbox-api": "^0.0.18",
"codesandbox-api": "^0.0.20",
"codesandbox-import-utils": "1.3.5",
"color": "^0.11.4",
"compare-versions": "^3.1.0",
Expand Down
5 changes: 4 additions & 1 deletion packages/app/src/app/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { mainModule, defaultOpenedModule } from './utils/main-module';
export function getSandbox({ props, api, path }) {
return api
.get(`/sandboxes/${props.id}`)
.then(data => path.success({ sandbox: data }))
.then(data => {
// data.template = 'custom';
return path.success({ sandbox: data });
})
.catch(error => {
if (error.response.status === 404) {
return path.notFound();
Expand Down
56 changes: 37 additions & 19 deletions packages/app/src/sandbox/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ const PREINSTALLED_DEPENDENCIES = [
'babel-plugin-transform-vue-jsx',
'babel-plugin-jsx-pragmatic',
'flow-bin',
...BABEL_DEPENDENCIES,
];

function getDependencies(parsedPackage, templateDefinition, configurations) {
Expand Down Expand Up @@ -250,13 +251,16 @@ function getDependencies(parsedPackage, templateDefinition, configurations) {
}
});

let preinstalledDependencies = PREINSTALLED_DEPENDENCIES;
if (templateDefinition.name !== 'babel-repl') {
preinstalledDependencies = [
...preinstalledDependencies,
...BABEL_DEPENDENCIES,
];
}
const sandpackConfig =
(configurations.customTemplate &&
configurations.customTemplate.parsed &&
configurations.customTemplate.parsed.sandpack) ||
{};

const preinstalledDependencies =
sandpackConfig.preInstalledDependencies == null
? PREINSTALLED_DEPENDENCIES
: sandpackConfig.preInstalledDependencies;

if (templateDefinition.name === 'reason') {
returnedDependencies = {
Expand Down Expand Up @@ -291,12 +295,15 @@ async function updateManager(
managerModules,
manifest,
configurations,
isNewCombination
isNewCombination,
hasFileResolver
) {
let newManager = false;
if (!manager || manager.id !== sandboxId) {
newManager = true;
manager = new Manager(sandboxId, getPreset(template), managerModules);
manager = new Manager(sandboxId, getPreset(template), managerModules, {
hasFileResolver,
});
}

if (isNewCombination || newManager) {
Expand Down Expand Up @@ -327,6 +334,8 @@ function getDocumentHeight() {
html.scrollHeight,
html.offsetHeight
);

return height;
}

function sendResize() {
Expand Down Expand Up @@ -379,6 +388,8 @@ async function compile({
entry,
showOpenInCodeSandbox = false,
skipEval = false,
hasFileResolver = false,
disableDependencyPreprocessing = false,
}) {
dispatch({
type: 'start',
Expand Down Expand Up @@ -438,7 +449,10 @@ async function compile({
templateDefinition,
configurations
);
const { manifest, isNewCombination } = await loadDependencies(dependencies);
const { manifest, isNewCombination } = await loadDependencies(
dependencies,
disableDependencyPreprocessing
);

if (isNewCombination && !firstLoad) {
// Just reset the whole manager if it's a new combination
Expand All @@ -449,14 +463,16 @@ async function compile({
}
const t = Date.now();

await updateManager(
sandboxId,
template,
modules,
manifest,
configurations,
isNewCombination
);
const updatedModules =
(await updateManager(
sandboxId,
template,
modules,
manifest,
configurations,
isNewCombination,
hasFileResolver
)) || [];

const possibleEntries = templateDefinition.getEntries(configurations);

Expand All @@ -475,6 +491,8 @@ async function compile({
const main = absolute(foundMain);
managerModuleToTranspile = modules[main];

await manager.preset.setup(manager, updatedModules);

dispatch({ type: 'status', status: 'transpiling' });
manager.setStage('transpilation');

Expand Down Expand Up @@ -650,7 +668,7 @@ async function compile({

if (manager) {
const managerState = {
...manager.serialize(),
...manager.serialize(false),
};
delete managerState.cachedPaths;
managerState.entry = managerModuleToTranspile
Expand Down
4 changes: 4 additions & 0 deletions packages/app/src/sandbox/eval/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export async function saveCache(
changes: number,
firstRun: boolean
) {
if (!sandboxId) {
return;
}

const managerState = {
...manager.serialize(),
};
Expand Down
4 changes: 4 additions & 0 deletions packages/app/src/sandbox/eval/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
cxjs,
babel,
dojo,
custom,
reason,
} from 'common/templates';

Expand All @@ -24,6 +25,7 @@ import babelPreset from './presets/babel-repl';
import cxjsPreset from './presets/cxjs';
import reasonPreset from './presets/reason';
import dojoPreset from './presets/dojo';
import customPreset from './presets/custom';

export default function getPreset(template: string) {
switch (template) {
Expand All @@ -49,6 +51,8 @@ export default function getPreset(template: string) {
return cxjsPreset();
case dojo.name:
return dojoPreset();
case custom.name:
return customPreset();
default:
return reactPreset();
}
Expand Down
Loading