New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@herberttn/bytenode-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@herberttn/bytenode-webpack-plugin - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0-rc.1

8

CHANGELOG.md

@@ -0,1 +1,9 @@

# [1.2.0-rc.1](https://github.com/herberttn/bytenode-webpack-plugin/compare/v1.1.0...v1.2.0-rc.1) (2021-04-03)
### Features
* better entry middlewares support ([25218e5](https://github.com/herberttn/bytenode-webpack-plugin/commit/25218e5402013d54402f934f0b6ee231b6e508ae))
* depend on webpack as peer only ([2724ee2](https://github.com/herberttn/bytenode-webpack-plugin/commit/2724ee23b46848141e49d8aacbbb7f61394473f1))
# [1.1.0](https://github.com/herberttn/bytenode-webpack-plugin/compare/v1.0.2...v1.1.0) (2021-04-01)

@@ -2,0 +10,0 @@

2

lib/index.d.ts

@@ -12,3 +12,3 @@ import type { WebpackPluginInstance } from 'webpack';

removeExtension(location: string): string;
preprocessOutput({ output }: WebpackOptionsNormalized): PreprocessedOutput;
preprocessOutput({ context, output }: WebpackOptionsNormalized): PreprocessedOutput;
preprocessEntry({ context, entry }: WebpackOptionsNormalized): PreprocessedEntry[];

@@ -15,0 +15,0 @@ debug(title: unknown, data: unknown, ...rest: unknown[]): void;

@@ -100,11 +100,5 @@ "use strict";

const virtualModules = [];
for (const { entry, compiled, loader, middlewares } of this.preprocessEntry(options)) {
for (const { entry, compiled, loader } of this.preprocessEntry(options)) {
const entryName = output.name ?? entry.name;
const addMiddlewares = (location) => {
if (Array.isArray(middlewares) && middlewares.length > 0) {
return [location, ...middlewares];
}
return location;
};
entries.push([entryName, addMiddlewares(loader.location)]);
entries.push([entryName, loader.locations.map(e => e.location)]);
entryLoaders.push(entryName);

@@ -118,5 +112,9 @@ const { name } = compiled;

}
entries.push([name, addMiddlewares(entry.location)]);
entries.push([name, entry.locations.map(e => e.location)]);
externals.push(relativeImportPath);
virtualModules.push([loader.location, createLoaderCode(relativeImportPath)]);
for (const e of loader.locations) {
if (!e.dependency) {
virtualModules.push([e.location, createLoaderCode(relativeImportPath)]);
}
}
}

@@ -145,9 +143,8 @@ return {

}
preprocessOutput({ output }) {
preprocessOutput({ context, output }) {
let filename = output?.filename ?? '[name].js';
const { directory, extension, name } = prepare(filename);
const { extension, name } = prepare(context, filename);
const dynamic = /.*[[\]]+.*/.test(filename);
filename = dynamic ? filename : '[name]' + extension;
return {
directory,
dynamic,

@@ -165,8 +162,5 @@ extension,

}
if (typeof entry === 'string') {
if (typeof entry === 'string' || Array.isArray(entry)) {
entries = [[undefined, entry]];
}
else if (Array.isArray(entry)) {
entries = entry.map(entry => [undefined, entry]);
}
else {

@@ -176,16 +170,7 @@ entries = Object.entries(entry);

return entries.map(([name, location]) => {
const middlewares = [];
if (Array.isArray(location)) {
const [entry, ...rest] = location;
location = entry;
middlewares.push(...rest);
}
if (context && !path_1.default.isAbsolute(location)) {
location = path_1.default.resolve(context, location);
}
const entry = prepare(location, name);
const compiled = prepare(location, name, '.compiled');
const loader = prepare(location, name, '.loader');
const entry = prepare(context, location, name);
const compiled = prepare(context, location, name, '.compiled');
const loader = prepare(context, location, name, '.loader');
return {
compiled, entry, loader, middlewares,
compiled, entry, loader,
};

@@ -245,13 +230,44 @@ });

}
function prepare(location, name, suffix = '') {
const directory = path_1.default.dirname(location);
const extension = path_1.default.extname(location);
const basename = path_1.default.basename(location, extension) + suffix;
const filename = basename + extension;
function prepare(context, location, name, suffix = '') {
const locationArray = Array.isArray(location) ? location : [location];
const locations = locationArray.map(location => {
const dependency = isDependency(location);
if (dependency) {
return {
dependency,
location,
};
}
if (context && !path_1.default.isAbsolute(location)) {
location = path_1.default.resolve(context, location);
}
const directory = path_1.default.dirname(location);
const extension = path_1.default.extname(location);
const basename = path_1.default.basename(location, extension) + suffix;
const filename = basename + extension;
location = path_1.default.join(directory, filename);
return {
basename,
dependency,
location,
};
});
let basename = 'main' + suffix;
if (locations.length === 1) {
const [single] = locations;
basename = single.basename ?? basename;
}
name = name ? name + suffix : basename;
location = path_1.default.join(directory, filename);
return {
basename, directory, extension, filename, location, name, suffix,
extension: '.js', locations, name,
};
function isDependency(module) {
try {
return typeof require.resolve(module) === 'string';
}
catch (_) {
return false;
}
}
}
//# sourceMappingURL=index.js.map

@@ -11,10 +11,10 @@ interface Options {

interface Prepared {
basename: string;
directory: string;
extension: string;
filename: string;
location: string;
locations: PreparedLocation[];
name: string;
suffix: string;
}
interface PreparedLocation {
dependency: boolean;
location: string;
}
interface PreprocessedEntry {

@@ -24,6 +24,4 @@ entry: Prepared;

loader: Prepared;
middlewares: string[];
}
interface PreprocessedOutput {
directory: string;
dynamic: boolean;

@@ -30,0 +28,0 @@ extension: string;

{
"name": "@herberttn/bytenode-webpack-plugin",
"description": "Compile JavaScript into bytecode using bytenode",
"version": "1.1.0",
"version": "1.2.0-rc.1",
"license": "MIT",

@@ -27,5 +27,7 @@ "repository": {

"bytenode": "^1.2.1",
"webpack": "^4.46.0",
"webpack-virtual-modules": "^0.4.2"
},
"peerDependencies": {
"webpack": "4.x"
},
"devDependencies": {

@@ -48,2 +50,3 @@ "@jest/types": "26.6.2",

"typescript": "4.2.3",
"webpack-hot-middleware": "2.25.0",
"webpack-merge": "5.7.3"

@@ -50,0 +53,0 @@ },

@@ -35,3 +35,3 @@ @herberttn/bytenode-webpack-plugin

- :heavy_check_mark: `entry` as an `object` (e.g., `{ main: 'src/index.js' }`)
- :heavy_exclamation_mark: `entry` middlewares (e.g., `['src/index.js', 'webpack-hot-middleware/client']`)
- :heavy_check_mark: `entry` middlewares (e.g., `['src/index.js', 'webpack-hot-middleware/client']`)
- :heavy_check_mark: Dynamic `output.filename` (e.g., `'[name].js'`)

@@ -38,0 +38,0 @@ - :heavy_check_mark: Named `output.filename` (e.g., `'index.js'`)

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