File tree Expand file tree Collapse file tree 4 files changed +23
-12
lines changed
app/pages/Sandbox/Editor/Workspace/Dependencies/VersionEntry Expand file tree Collapse file tree 4 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -61,14 +61,18 @@ export default class VersionEntry extends React.PureComponent {
6161 }
6262
6363 componentWillMount ( ) {
64- const versionRegex = / ^ \d { 1 , 3 } \. \d { 1 , 3 } .\d { 1 , 3 } $ / ;
65- const version = this . props . dependencies [ this . props . dependency ] ;
66- const cleanVersion = version . split ( '^' ) ;
67- this . getSizeForPKG (
68- `${ this . props . dependency } @${ cleanVersion [ cleanVersion . length - 1 ] } `
69- ) ;
70- if ( ! versionRegex . test ( version ) ) {
71- this . setVersionsForLatestPkg ( `${ this . props . dependency } @${ version } ` ) ;
64+ try {
65+ const versionRegex = / ^ \d { 1 , 3 } \. \d { 1 , 3 } .\d { 1 , 3 } $ / ;
66+ const version = this . props . dependencies [ this . props . dependency ] ;
67+ const cleanVersion = version . split ( '^' ) ;
68+ this . getSizeForPKG (
69+ `${ this . props . dependency } @${ cleanVersion [ cleanVersion . length - 1 ] } `
70+ ) ;
71+ if ( ! versionRegex . test ( version ) ) {
72+ this . setVersionsForLatestPkg ( `${ this . props . dependency } @${ version } ` ) ;
73+ }
74+ } catch ( e ) {
75+ console . error ( e ) ;
7276 }
7377 }
7478
Original file line number Diff line number Diff line change @@ -22,10 +22,10 @@ import coreLibraries from './npm/get-core-libraries';
2222import getDependencyName from './utils/get-dependency-name' ;
2323import TestRunner from './tests/jest-lite' ;
2424import dependenciesToQuery from '../npm/dependencies-to-query' ;
25- import isESModule from './utils/is-es-module' ;
2625import { packageFilter } from './utils/resolve-utils' ;
2726
2827import { ignoreNextCache , deleteAPICache } from './cache' ;
28+ import { shouldTranspile } from './transpilers/babel/check' ;
2929
3030type Externals = {
3131 [ name : string ] : string ,
@@ -292,7 +292,7 @@ export default class Manager {
292292
293293 // Check if module syntax, only transpile when that's NOT the case
294294 // TODO move this check to the packager
295- if ( ! isESModule ( module . code ) ) {
295+ if ( ! shouldTranspile ( module . code , path ) ) {
296296 module . requires = this . manifest . contents [ path ] . requires ;
297297 }
298298
Original file line number Diff line number Diff line change 1+ import isESModule from '../../utils/is-es-module' ;
2+
3+ const JSXSyntax = / < \w / ;
4+
5+ export function shouldTranspile ( code : string , path : string ) {
6+ return isESModule ( code ) || JSXSyntax . test ( code ) ;
7+ }
Original file line number Diff line number Diff line change 22import BabelWorker from 'worker-loader?publicPath=/&name=babel-transpiler.[hash:8].worker.js!./worker/index.js' ;
33import { isBabel7 } from 'common/utils/is-babel-7' ;
44
5- import isESModule from '../../utils/is-es-module' ;
65import regexGetRequireStatements from './worker/simple-get-require-statements' ;
76import getBabelConfig from './babel-parser' ;
87import WorkerTranspiler from '../worker-transpiler' ;
98import { type LoaderContext } from '../../transpiled-module' ;
109import type { default as Manager } from '../../manager' ;
1110
1211import delay from '../../../utils/delay' ;
12+ import { shouldTranspile } from './check' ;
1313
1414// Right now this is in a worker, but when we're going to allow custom plugins
1515// we need to move this out of the worker again, because the config needs
@@ -50,7 +50,7 @@ class BabelTranspiler extends WorkerTranspiler {
5050 if (
5151 ( loaderContext . options . simpleRequire ||
5252 path . startsWith ( '/node_modules' ) ) &&
53- ! isESModule ( code )
53+ ! shouldTranspile ( code , path )
5454 ) {
5555 regexGetRequireStatements ( code ) . forEach ( dependency => {
5656 if ( dependency . isGlob ) {
You can’t perform that action at this time.
0 commit comments