@@ -53,10 +53,11 @@ module.exports = function scriptLoader(content) {
5353 const outputFile = ( rawContent , isFromNpm = true ) => {
5454 let distSourcePath ;
5555 if ( isFromNpm ) {
56- const relativeNpmPath = relative ( currentNodeModulePath , this . resourcePath ) ;
57- const splitedNpmPath = relativeNpmPath . split ( sep ) ;
58- if ( / ^ _ ? @ / . test ( relativeNpmPath ) ) splitedNpmPath . shift ( ) ; // Extra shift for scoped npm.
59- splitedNpmPath . shift ( ) ; // Skip npm module package, for cnpm/tnpm will rewrite this.
56+ // 以下四行开销测下来用不到,故注释
57+ // const relativeNpmPath = relative(currentNodeModulePath, this.resourcePath);
58+ // const splitedNpmPath = relativeNpmPath.split(sep);
59+ // if (/^_?@/.test(relativeNpmPath)) splitedNpmPath.shift(); // Extra shift for scoped npm.
60+ // splitedNpmPath.shift(); // Skip npm module package, for cnpm/tnpm will rewrite this.
6061 distSourcePath = normalizeNpmFileName ( join ( outputPath , 'npm' , relative ( rootNodeModulePath , this . resourcePath ) ) ) ;
6162 } else {
6263 const relativeFilePath = relative (
@@ -258,7 +259,10 @@ module.exports = function scriptLoader(content) {
258259 content
259260 ] . join ( '\n' ) ;
260261 } else if ( ! isAppJSon ) {
261- outputFile ( rawContent , false ) ;
262+ // outputFile(rawContent, false);
263+ // content 是过了 rax-platform-loader 的(会包含 env 变量转换为布尔常量化),而 rawContent 是没有这个转换的;
264+ // 后续的 babel-plugin-minify-dead-code-elimination-while-loop-fixed 依赖布尔常量来 tree-shaking.
265+ outputFile ( content , false ) ;
262266 }
263267
264268 return isJSON ? '{}' : transformCode (
0 commit comments