File tree Expand file tree Collapse file tree 10 files changed +23
-18
lines changed
Expand file tree Collapse file tree 10 files changed +23
-18
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,13 @@ import { absolute } from 'common/utils/path';
33import _debug from 'app/utils/debug' ;
44import parseConfigurations from 'common/templates/configuration/parse' ;
55import initializeErrorTransformers from 'sandbox-hooks/errors/transformers' ;
6+ import { inject , unmount } from 'sandbox-hooks/react-error-overlay/overlay' ;
67
78import getPreset from './eval' ;
89import Manager from './eval/manager' ;
910
1011import { resetScreen } from './status-screen' ;
1112
12- import { inject , unmount } from 'sandbox-hooks/react-error-overlay/overlay' ;
1313import createCodeSandboxOverlay from './codesandbox-overlay' ;
1414import handleExternalResources from './external-resources' ;
1515
Original file line number Diff line number Diff line change @@ -540,6 +540,7 @@ export default class Manager {
540540
541541 const dependencyName = getDependencyName ( connectedPath ) ;
542542
543+ // TODO: fix the stack hack
543544 if (
544545 this . manifest . dependencies . find ( d => d . name === dependencyName ) ||
545546 this . manifest . dependencyDependencies [ dependencyName ]
@@ -579,16 +580,22 @@ export default class Manager {
579580
580581 resolveTranspiledModuleAsync = (
581582 path : string ,
582- currentPath : string ,
583+ currentTModule : ? TranspiledModule ,
583584 ignoredExtensions ?: Array < string >
584585 ) : Promise < TranspiledModule > => {
586+ const tModule =
587+ currentTModule || this . getTranspiledModule ( this . modules [ '/package.json' ] ) ; // Get arbitrary file from root
585588 try {
586589 return Promise . resolve (
587- this . resolveTranspiledModule ( path , currentPath , ignoredExtensions )
590+ this . resolveTranspiledModule (
591+ path ,
592+ tModule . module . path ,
593+ ignoredExtensions
594+ )
588595 ) ;
589596 } catch ( e ) {
590597 if ( e . type === 'module-not-found' && e . isDependency ) {
591- return this . downloadDependency ( e . path , currentPath , ignoredExtensions ) ;
598+ return this . downloadDependency ( e . path , tModule , ignoredExtensions ) ;
592599 }
593600
594601 throw e ;
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ async function addAngularJSONResources(manager) {
6767
6868 const tModule = await manager . resolveTranspiledModuleAsync (
6969 finalPath ,
70- '/'
70+ null
7171 ) ;
7272
7373 await tModule . transpile ( manager ) ;
@@ -80,7 +80,7 @@ async function addAngularJSONResources(manager) {
8080 const finalPath = absolute ( join ( project . root , p ) ) ;
8181 const tModule = await manager . resolveTranspiledModuleAsync (
8282 finalPath ,
83- '/'
83+ null
8484 ) ;
8585 tModule . setIsEntry ( true ) ;
8686 return tModule . transpile ( manager ) ;
@@ -107,7 +107,7 @@ async function addAngularCLIResources(manager) {
107107
108108 const tModule = await manager . resolveTranspiledModuleAsync (
109109 finalPath ,
110- '/'
110+ null
111111 ) ;
112112
113113 await tModule . transpile ( manager ) ;
@@ -121,7 +121,7 @@ async function addAngularCLIResources(manager) {
121121 const finalPath = absolute ( join ( app . root || 'src' , p ) ) ;
122122 const tModule = await manager . resolveTranspiledModuleAsync (
123123 finalPath ,
124- '/'
124+ null
125125 ) ;
126126 tModule . setIsEntry ( true ) ;
127127 return tModule . transpile ( manager ) ;
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ function isVersion2(configurations) {
2323 return semver . intersects ( reactScriptsVersion , '^2.0.0' ) ;
2424 }
2525
26- return true ;
26+ return false ;
2727}
2828
2929export default function initialize ( ) {
Original file line number Diff line number Diff line change @@ -16,10 +16,11 @@ export default function initialize() {
1616 {
1717 setup : async manager => {
1818 const stylesPath = absolute ( join ( 'src' , 'main.css' ) ) ;
19+
1920 try {
2021 const tModule = await manager . resolveTranspiledModuleAsync (
2122 stylesPath ,
22- '/'
23+ null
2324 ) ;
2425 await tModule . transpile ( manager ) ;
2526 tModule . setIsEntry ( true ) ;
Original file line number Diff line number Diff line change @@ -461,7 +461,7 @@ export default class TranspiledModule {
461461 resolveTranspiledModuleAsync : ( depPath : string , options = { } ) = >
462462 manager . resolveTranspiledModuleAsync (
463463 depPath ,
464- options . isAbsolute ? '/' : this . module . path ,
464+ options . isAbsolute ? null : this ,
465465 options . ignoredExtensions
466466 ) ,
467467 getModules : ( ) : Array < Module > => manager . getModules ( ) ,
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ const resolveAsyncModule = (
2424 { ignoredExtensions } ?: { ignoredExtensions ?: Array < string > }
2525) =>
2626 new Promise ( ( r , reject ) => {
27- const sendId = Math . random ( ) * 10000 ;
27+ const sendId = Math . floor ( Math . random ( ) * 10000 ) ;
2828 self . postMessage ( {
2929 type : 'resolve-async-transpiled-module' ,
3030 path,
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ requirePolyfills().then(() => {
7878 sendReady ( ) ;
7979
8080 setupHistoryListeners ( ) ;
81- setupConsole ( ) ;
81+ // setupConsole();
8282 }
8383
8484 if ( process . env . NODE_ENV === 'test' || isStandalone ) {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -5,8 +5,9 @@ type Suggestion = {
55 title : string ,
66 action : Function ,
77} ;
8+ const ErrorClass = Error ;
89
9- export default class SandboxError extends Error {
10+ export default class SandboxError extends ErrorClass {
1011 severity : 'error' | 'warning' ;
1112 type : string ;
1213 module : Module ;
You can’t perform that action at this time.
0 commit comments