Socket
Socket
Sign inDemoInstall

@web/dev-server-rollup

Package Overview
Dependencies
Maintainers
7
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web/dev-server-rollup - npm Package Compare versions

Comparing version 0.2.13 to 0.3.0

11

CHANGELOG.md
# @web/dev-server-rollup
## 0.3.0
### Minor Changes
- 0f613e0e: handle modules resolved outside root dir
### Patch Changes
- Updated dependencies [0f613e0e]
- @web/dev-server-core@0.3.0
## 0.2.13

@@ -4,0 +15,0 @@

41

dist/rollupAdapter.js

@@ -131,19 +131,30 @@ "use strict";

}
if (!path_1.default.normalize(resolvedImportPath).startsWith(rootDir)) {
const errorMessage = chalk_1.red(`\n\nResolved ${chalk_1.cyanBright(source)} to ${chalk_1.cyanBright(resolvedImportPath)}.\n\n`) +
chalk_1.red('This path is not reachable from the browser because') +
chalk_1.red(` it is outside root directory ${chalk_1.cyanBright(rootDir)}\n\n`) +
chalk_1.red(`Configure the root directory using the ${chalk_1.cyanBright('--root-dir')}`) +
chalk_1.red(` flag or ${chalk_1.cyanBright('rootDir')} option.\n`);
if (typeof code === 'string' && typeof column === 'number' && typeof line === 'number') {
throw new dev_server_core_1.PluginSyntaxError(errorMessage, filePath, code, column, line);
const normalizedPath = path_1.default.normalize(resolvedImportPath);
if (!normalizedPath.startsWith(rootDir)) {
const relativePath = path_1.default.relative(rootDir, normalizedPath);
const dirUp = `..${path_1.default.sep}`;
const lastDirUpIndex = relativePath.lastIndexOf(dirUp) + 3;
const dirUpStrings = relativePath.substring(0, lastDirUpIndex).split(path_1.default.sep);
if (dirUpStrings.length === 0 || dirUpStrings.some(str => !['..', ''].includes(str))) {
// we expect the relative part to consist of only ../ or ..\\
const errorMessage = chalk_1.red(`\n\nResolved ${chalk_1.cyanBright(source)} to ${chalk_1.cyanBright(resolvedImportPath)}.\n\n`) +
chalk_1.red('This path could not be converted to a browser path. Please file an issue with a reproduction.');
if (typeof code === 'string' &&
typeof column === 'number' &&
typeof line === 'number') {
throw new dev_server_core_1.PluginSyntaxError(errorMessage, filePath, code, column, line);
}
else {
throw new dev_server_core_1.PluginError(errorMessage);
}
}
else {
throw new dev_server_core_1.PluginError(errorMessage);
}
const importPath = utils_1.toBrowserPath(relativePath.substring(lastDirUpIndex));
resolvedImportPath = `/__wds-outside-root__/${dirUpStrings.length - 1}/${importPath}`;
}
const resolveRelativeTo = path_1.default.extname(filePath) ? path_1.default.dirname(filePath) : filePath;
const relativeImportFilePath = path_1.default.relative(resolveRelativeTo, resolvedImportPath);
const importBrowserPath = `${utils_1.toBrowserPath(relativeImportFilePath)}`;
return `./${importBrowserPath}${importSuffix}`;
else {
const resolveRelativeTo = path_1.default.extname(filePath) ? path_1.default.dirname(filePath) : filePath;
const relativeImportFilePath = path_1.default.relative(resolveRelativeTo, resolvedImportPath);
resolvedImportPath = `./${utils_1.toBrowserPath(relativeImportFilePath)}`;
}
return `${resolvedImportPath}${importSuffix}`;
}

@@ -150,0 +161,0 @@ catch (error) {

@@ -15,3 +15,3 @@ "use strict";

function toBrowserPath(filePath) {
return filePath.replace(new RegExp(path_1.default.sep === '\\' ? '\\\\' : path_1.default.sep, 'g'), '/');
return filePath.split(path_1.default.sep).join('/');
}

@@ -18,0 +18,0 @@ exports.toBrowserPath = toBrowserPath;

{
"name": "@web/dev-server-rollup",
"version": "0.2.13",
"version": "0.3.0",
"publishConfig": {

@@ -50,6 +50,6 @@ "access": "public"

"dependencies": {
"@web/dev-server-core": "^0.2.17",
"@web/dev-server-core": "^0.3.0",
"chalk": "^4.1.0",
"parse5": "^6.0.1",
"rollup": "^2.34.2",
"rollup": "^2.35.1",
"whatwg-url": "^8.4.0"

@@ -61,13 +61,9 @@ },

"@rollup/plugin-babel": "^5.2.2",
"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-image": "^2.0.5",
"@rollup/plugin-inject": "^4.0.2",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"@rollup/plugin-replace": "^2.3.4",
"@rollup/plugin-url": "^6.0.0",
"@types/parse5": "^5.0.3",
"@types/whatwg-url": "^8.0.0",
"@web/test-runner-chrome": "^0.7.0",
"@web/test-runner-core": "^0.8.12",
"@web/test-runner-chrome": "^0.8.0",
"@web/test-runner-core": "^0.9.0",
"chai": "^4.2.0",

@@ -74,0 +70,0 @@ "node-fetch": "3.0.0-beta.9",

@@ -188,22 +188,35 @@ /* eslint-disable no-control-regex */

if (!path.normalize(resolvedImportPath).startsWith(rootDir)) {
const errorMessage =
red(`\n\nResolved ${cyanBright(source)} to ${cyanBright(resolvedImportPath)}.\n\n`) +
red('This path is not reachable from the browser because') +
red(` it is outside root directory ${cyanBright(rootDir)}\n\n`) +
red(`Configure the root directory using the ${cyanBright('--root-dir')}`) +
red(` flag or ${cyanBright('rootDir')} option.\n`);
const normalizedPath = path.normalize(resolvedImportPath);
if (!normalizedPath.startsWith(rootDir)) {
const relativePath = path.relative(rootDir, normalizedPath);
const dirUp = `..${path.sep}`;
const lastDirUpIndex = relativePath.lastIndexOf(dirUp) + 3;
const dirUpStrings = relativePath.substring(0, lastDirUpIndex).split(path.sep);
if (dirUpStrings.length === 0 || dirUpStrings.some(str => !['..', ''].includes(str))) {
// we expect the relative part to consist of only ../ or ..\\
const errorMessage =
red(`\n\nResolved ${cyanBright(source)} to ${cyanBright(resolvedImportPath)}.\n\n`) +
red(
'This path could not be converted to a browser path. Please file an issue with a reproduction.',
);
if (
typeof code === 'string' &&
typeof column === 'number' &&
typeof line === 'number'
) {
throw new PluginSyntaxError(errorMessage, filePath, code, column, line);
} else {
throw new PluginError(errorMessage);
}
}
if (typeof code === 'string' && typeof column === 'number' && typeof line === 'number') {
throw new PluginSyntaxError(errorMessage, filePath, code, column, line);
} else {
throw new PluginError(errorMessage);
}
const importPath = toBrowserPath(relativePath.substring(lastDirUpIndex));
resolvedImportPath = `/__wds-outside-root__/${dirUpStrings.length - 1}/${importPath}`;
} else {
const resolveRelativeTo = path.extname(filePath) ? path.dirname(filePath) : filePath;
const relativeImportFilePath = path.relative(resolveRelativeTo, resolvedImportPath);
resolvedImportPath = `./${toBrowserPath(relativeImportFilePath)}`;
}
const resolveRelativeTo = path.extname(filePath) ? path.dirname(filePath) : filePath;
const relativeImportFilePath = path.relative(resolveRelativeTo, resolvedImportPath);
const importBrowserPath = `${toBrowserPath(relativeImportFilePath)}`;
return `./${importBrowserPath}${importSuffix}`;
return `${resolvedImportPath}${importSuffix}`;
} catch (error) {

@@ -210,0 +223,0 @@ throw wrapRollupError(filePath, context, error);

@@ -11,3 +11,3 @@ import path from 'path';

export function toBrowserPath(filePath: string) {
return filePath.replace(new RegExp(path.sep === '\\' ? '\\\\' : path.sep, 'g'), '/');
return filePath.split(path.sep).join('/');
}

@@ -14,0 +14,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc