mesh-devtool
Advanced tools
Comparing version
{ | ||
"name": "mesh-devtool", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"main": "index.js", | ||
@@ -74,3 +74,3 @@ "license": "MIT", | ||
"vue-template-compiler": "^2.1.10", | ||
"webpack": "^4.16.2", | ||
"webpack": "^2.6.1", | ||
"webpack-bundle-analyzer": "^2.2.1", | ||
@@ -77,0 +77,0 @@ "webpack-cli": "^3.1.0", |
@@ -34,2 +34,3 @@ const path = require('path') | ||
}, | ||
/* | ||
{ | ||
@@ -39,2 +40,3 @@ test: /\.tsx?$/, | ||
}, | ||
*/ | ||
{ | ||
@@ -41,0 +43,0 @@ test: /\.css$/, |
@@ -30,3 +30,3 @@ // @remove-on-eject-begin | ||
require.resolve('./polyfills'), | ||
paths.appIndexTs | ||
paths.appIndexJs | ||
], | ||
@@ -43,2 +43,7 @@ output: { | ||
plugins: [ | ||
// Generates an `index.html` file with the <script> injected. | ||
new HtmlWebpackPlugin({ | ||
inject: true, | ||
template: paths.appHtml | ||
}), | ||
// Makes some environment variables available in index.html. | ||
@@ -49,7 +54,2 @@ // The public URL is available as %PUBLIC_URL% in index.html, e.g.: | ||
new InterpolateHtmlPlugin(env.raw), | ||
// Generates an `index.html` file with the <script> injected. | ||
new HtmlWebpackPlugin({ | ||
inject: true, | ||
template: paths.appHtml | ||
}), | ||
// Makes some environment variables available to the JS code, for example: | ||
@@ -56,0 +56,0 @@ // if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`. |
@@ -43,3 +43,3 @@ const path = require('path') | ||
require.resolve('./polyfills'), | ||
paths.appIndexTs | ||
paths.appIndexJs | ||
], | ||
@@ -64,8 +64,2 @@ output: { | ||
plugins: [ | ||
// Makes some environment variables available in index.html. | ||
// The public URL is available as %PUBLIC_URL% in index.html, e.g.: | ||
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> | ||
// In production, it will be an empty string unless you specify "homepage" | ||
// in `package.json`, in which case it will be the pathname of that URL. | ||
new InterpolateHtmlPlugin(env.raw), | ||
// Generates an `index.html` file with the <script> injected. | ||
@@ -89,2 +83,8 @@ new HtmlWebpackPlugin({ | ||
}), | ||
// Makes some environment variables available in index.html. | ||
// The public URL is available as %PUBLIC_URL% in index.html, e.g.: | ||
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> | ||
// In production, it will be an empty string unless you specify "homepage" | ||
// in `package.json`, in which case it will be the pathname of that URL. | ||
new InterpolateHtmlPlugin(env.raw), | ||
// Makes some environment variables available to the JS code, for example: | ||
@@ -91,0 +91,0 @@ // if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`. |
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
@@ -30,7 +28,7 @@ | ||
{ | ||
compiler.plugin('compilation', compilation => | ||
compiler.hooks.compilation.tap('InterpolateHtmlPlugin', compilation => | ||
{ | ||
compilation.plugin( | ||
'html-webpack-plugin-before-html-processing', | ||
(data, callback) => | ||
compilation.hooks.htmlWebpackPluginBeforeHtmlProcessing.tap( | ||
'InterpolateHtmlPlugin', | ||
data => | ||
{ | ||
@@ -46,3 +44,2 @@ // Run HTML through a series of user-specified string replacements. | ||
}); | ||
callback(null, data); | ||
} | ||
@@ -54,2 +51,2 @@ ); | ||
module.exports = InterpolateHtmlPlugin; | ||
module.exports = InterpolateHtmlPlugin; |
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
@@ -17,5 +15,6 @@ | ||
{ | ||
constructor(appSrc) | ||
constructor(appSrc, allowedFiles = []) | ||
{ | ||
this.appSrc = appSrc; | ||
this.appSrcs = Array.isArray(appSrc) ? appSrc : [appSrc]; | ||
this.allowedFiles = new Set(allowedFiles); | ||
} | ||
@@ -25,61 +24,82 @@ | ||
{ | ||
const { appSrc } = this; | ||
resolver.plugin('file', (request, callback) => | ||
{ | ||
// Unknown issuer, probably webpack internals | ||
if (!request.context.issuer) | ||
const { appSrcs } = this; | ||
resolver.hooks.file.tapAsync( | ||
'ModuleScopePlugin', | ||
(request, contextResolver, callback) => | ||
{ | ||
return callback(); | ||
} | ||
if ( | ||
// If this resolves to a node_module, we don't care what happens next | ||
request.descriptionFileRoot.indexOf('/node_modules/') !== -1 || | ||
request.descriptionFileRoot.indexOf('\\node_modules\\') !== -1 || | ||
// Make sure this request was manual | ||
!request.__innerRequest_request | ||
) | ||
{ | ||
return callback(); | ||
} | ||
// Resolve the issuer from our appSrc and make sure it's one of our files | ||
// Maybe an indexOf === 0 would be better? | ||
const relative = path.relative(appSrc, request.context.issuer); | ||
// If it's not in src/ or a subdirectory, not our request! | ||
if ( | ||
relative.startsWith('../') || | ||
relative.startsWith('..\\') | ||
) | ||
{ | ||
return callback(); | ||
} | ||
// Find path from src to the requested file | ||
const requestRelative = path.relative( | ||
appSrc, | ||
path.resolve( | ||
// Unknown issuer, probably webpack internals | ||
if (!request.context.issuer) | ||
{ | ||
return callback(); | ||
} | ||
if ( | ||
// If this resolves to a node_module, we don't care what happens next | ||
request.descriptionFileRoot.indexOf('/node_modules/') !== -1 || | ||
request.descriptionFileRoot.indexOf('\\node_modules\\') !== -1 || | ||
// Make sure this request was manual | ||
!request.__innerRequest_request | ||
) | ||
{ | ||
return callback(); | ||
} | ||
// Resolve the issuer from our appSrc and make sure it's one of our files | ||
// Maybe an indexOf === 0 would be better? | ||
if ( | ||
appSrcs.every(appSrc => | ||
{ | ||
const relative = path.relative(appSrc, request.context.issuer); | ||
// If it's not in one of our app src or a subdirectory, not our request! | ||
return relative.startsWith('../') || relative.startsWith('..\\'); | ||
}) | ||
) | ||
{ | ||
return callback(); | ||
} | ||
const requestFullPath = path.resolve( | ||
path.dirname(request.context.issuer), | ||
request.__innerRequest_request | ||
); | ||
if (this.allowedFiles.has(requestFullPath)) | ||
{ | ||
return callback(); | ||
} | ||
// Find path from src to the requested file | ||
// Error if in a parent directory of all given appSrcs | ||
if ( | ||
appSrcs.every(appSrc => | ||
{ | ||
const requestRelative = path.relative(appSrc, requestFullPath); | ||
return ( | ||
requestRelative.startsWith('../') || | ||
requestRelative.startsWith('..\\') | ||
); | ||
}) | ||
) | ||
); | ||
// Error if in a parent directory of src/ | ||
if ( | ||
requestRelative.startsWith('../') || | ||
requestRelative.startsWith('..\\') | ||
) | ||
{ | ||
callback( | ||
new Error( | ||
`You attempted to import ${chalk.cyan(request.__innerRequest_request)} which falls outside of the project ${chalk.cyan('src/')} directory. ` + | ||
`Relative imports outside of ${chalk.cyan('src/')} are not supported. ` + | ||
`You can either move it inside ${chalk.cyan('src/')}, or add a symlink to it from project's ${chalk.cyan('node_modules/')}.` | ||
), | ||
request | ||
); | ||
} else | ||
{ | ||
callback(); | ||
} | ||
}); | ||
{ | ||
callback( | ||
new Error( | ||
`You attempted to import ${chalk.cyan( | ||
request.__innerRequest_request | ||
)} which falls outside of the project ${chalk.cyan( | ||
'src/' | ||
)} directory. ` + | ||
`Relative imports outside of ${chalk.cyan( | ||
'src/' | ||
)} are not supported. ` + | ||
`You can either move it inside ${chalk.cyan( | ||
'src/' | ||
)}, or add a symlink to it from project's ${chalk.cyan( | ||
'node_modules/' | ||
)}.` | ||
), | ||
request | ||
); | ||
} else | ||
{ | ||
callback(); | ||
} | ||
}); | ||
} | ||
} | ||
module.exports = ModuleScopePlugin; | ||
module.exports = ModuleScopePlugin; |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3461
0.49%4
-20%1119609
-1.14%