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

@goji/webpack-plugin

Package Overview
Dependencies
Maintainers
2
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@goji/webpack-plugin - npm Package Compare versions

Comparing version 0.5.22 to 0.5.23

dist/cjs/loaders/configFile.d.ts

2

dist/cjs/index.js

@@ -6,3 +6,2 @@ "use strict";

const bridge_1 = require("./plugins/bridge");
const config_1 = require("./plugins/config");
const entry_1 = require("./plugins/entry");

@@ -24,3 +23,2 @@ const runtime_1 = require("./plugins/runtime");

new bridge_1.GojiBridgeWebpackPlugin(options).apply(compiler);
new config_1.GojiConfigWebpackPlugin(options).apply(compiler);
new entry_1.GojiEntryWebpackPlugin(options).apply(compiler);

@@ -27,0 +25,0 @@ new runtime_1.GojiRuntimePlugin(options).apply(compiler);

@@ -6,2 +6,4 @@ "use strict";

const core_1 = require("@goji/core");
const webpack_sources_1 = require("webpack-sources");
const deepmerge_1 = tslib_1.__importDefault(require("deepmerge"));
const components_1 = require("../utils/components");

@@ -29,18 +31,16 @@ const render_1 = require("../utils/render");

}
renderTemplateToAsset(compilation, assetPath, templatePath, data) {
renderTemplateToAsset(compilation, assetPath, templatePath, data, merge) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const formattedAssetPath = this.transformExtForPath(assetPath);
// skip existing asset
if (compilation.assets[formattedAssetPath] !== undefined) {
let content = yield this.renderTemplate(templatePath, data);
if (!merge && compilation.assets[formattedAssetPath] !== undefined) {
console.warn('skip existing asset', formattedAssetPath);
return;
}
let content = yield this.renderTemplate(templatePath, data);
if (merge && compilation.assets[formattedAssetPath]) {
content = merge(content, compilation.assets[formattedAssetPath].source());
}
if (this.options.minimize) {
content = minimize_1.minimize(content, path_1.default.extname(assetPath));
}
compilation.assets[formattedAssetPath] = {
source: () => content,
size: () => content.length,
};
compilation.assets[formattedAssetPath] = new webpack_sources_1.RawSource(content);
});

@@ -193,3 +193,3 @@ }

useWrappedComponent: this.useWrappedComponent(),
});
}, (newSource, oldSource) => JSON.stringify(deepmerge_1.default(JSON.parse(oldSource), JSON.parse(newSource)), null, 2));
}

@@ -196,0 +196,0 @@ }));

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
// @ts-ignore
const SingleEntryPlugin_1 = tslib_1.__importDefault(require("webpack/lib/SingleEntryPlugin"));
const webpack_1 = tslib_1.__importDefault(require("webpack"));
const path_1 = tslib_1.__importDefault(require("path"));
const loader_utils_1 = tslib_1.__importDefault(require("loader-utils"));
const replace_ext_1 = tslib_1.__importDefault(require("replace-ext"));
const shared_1 = require("../shared");

@@ -45,9 +43,8 @@ const based_1 = require("./based");

this.appConfig = loadConfig_1.loadConfig(entry, context, this.options.target);
const appEntry = 'app';
const pathEntries = readPathsFromAppConfig(this.appConfig);
// remove all ext for entry including `.config.js`
const appEntry = replace_ext_1.default(entry.replace(/\.config\.js$/, ''), '');
// add app & pages
for (const pathEntry of [appEntry, ...pathEntries]) {
const request = loader_utils_1.default.urlToRequest(pathEntry);
new SingleEntryPlugin_1.default(context, request, pathEntry).apply(compiler);
new webpack_1.default.SingleEntryPlugin(context, `${require.resolve('../loaders/configFile')}!${request}`, pathEntry).apply(compiler);
}

@@ -54,0 +51,0 @@ // save appEntry and pathEntries for other plugins

@@ -0,2 +1,3 @@

export declare const exec: (code: string, filename: string, context: string) => any;
export declare const CONFIG_FILE_SUFFIX = ".config.js";
export declare const loadConfig: (entrypoint: string, context: string | undefined, target: string) => any;

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

// from https://github.com/webpack/webpack.js.org/issues/1268#issuecomment-313513988
const exec = (code, filename, context) => {
exports.exec = (code, filename, context) => {
/* eslint-disable no-underscore-dangle */

@@ -55,3 +55,3 @@ const module = new module_1.default(filename, undefined);

const content = fs_1.default.readFileSync(resolvedPath).toString();
const jsContent = exec(content, resolvedPath, context);
const jsContent = exports.exec(content, resolvedPath, context);
if (typeof jsContent === 'function') {

@@ -58,0 +58,0 @@ return jsContent({ target });

import webpack from 'webpack';
import { GojiBridgeWebpackPlugin } from './plugins/bridge';
import { GojiConfigWebpackPlugin } from './plugins/config';
import { GojiEntryWebpackPlugin } from './plugins/entry';

@@ -20,3 +19,2 @@ import { GojiRuntimePlugin } from './plugins/runtime';

new GojiBridgeWebpackPlugin(options).apply(compiler);
new GojiConfigWebpackPlugin(options).apply(compiler);
new GojiEntryWebpackPlugin(options).apply(compiler);

@@ -23,0 +21,0 @@ new GojiRuntimePlugin(options).apply(compiler);

import { __awaiter } from "tslib";
import path from 'path';
import { unstable_SIMPLIFY_COMPONENTS as SIMPLIFY_COMPONENTS } from '@goji/core';
import { RawSource } from 'webpack-sources';
import deepmerge from 'deepmerge';
import { getWhitelistedComponents, getRenderedComponents } from '../utils/components';

@@ -26,18 +28,16 @@ import { renderTemplate } from '../utils/render';

}
renderTemplateToAsset(compilation, assetPath, templatePath, data) {
renderTemplateToAsset(compilation, assetPath, templatePath, data, merge) {
return __awaiter(this, void 0, void 0, function* () {
const formattedAssetPath = this.transformExtForPath(assetPath);
// skip existing asset
if (compilation.assets[formattedAssetPath] !== undefined) {
let content = yield this.renderTemplate(templatePath, data);
if (!merge && compilation.assets[formattedAssetPath] !== undefined) {
console.warn('skip existing asset', formattedAssetPath);
return;
}
let content = yield this.renderTemplate(templatePath, data);
if (merge && compilation.assets[formattedAssetPath]) {
content = merge(content, compilation.assets[formattedAssetPath].source());
}
if (this.options.minimize) {
content = minimize(content, path.extname(assetPath));
}
compilation.assets[formattedAssetPath] = {
source: () => content,
size: () => content.length,
};
compilation.assets[formattedAssetPath] = new RawSource(content);
});

@@ -190,3 +190,3 @@ }

useWrappedComponent: this.useWrappedComponent(),
});
}, (newSource, oldSource) => JSON.stringify(deepmerge(JSON.parse(oldSource), JSON.parse(newSource)), null, 2));
}

@@ -193,0 +193,0 @@ }));

@@ -1,6 +0,4 @@

// @ts-ignore
import SingleEntryPlugin from 'webpack/lib/SingleEntryPlugin';
import webpack from 'webpack';
import path from 'path';
import loaderUtils from 'loader-utils';
import replaceExt from 'replace-ext';
import { pathEntriesMap, appEntryMap } from '../shared';

@@ -42,9 +40,8 @@ import { GojiBasedWebpackPlugin } from './based';

this.appConfig = loadConfig(entry, context, this.options.target);
const appEntry = 'app';
const pathEntries = readPathsFromAppConfig(this.appConfig);
// remove all ext for entry including `.config.js`
const appEntry = replaceExt(entry.replace(/\.config\.js$/, ''), '');
// add app & pages
for (const pathEntry of [appEntry, ...pathEntries]) {
const request = loaderUtils.urlToRequest(pathEntry);
new SingleEntryPlugin(context, request, pathEntry).apply(compiler);
new webpack.SingleEntryPlugin(context, `${require.resolve('../loaders/configFile')}!${request}`, pathEntry).apply(compiler);
}

@@ -51,0 +48,0 @@ // save appEntry and pathEntries for other plugins

@@ -0,2 +1,3 @@

export declare const exec: (code: string, filename: string, context: string) => any;
export declare const CONFIG_FILE_SUFFIX = ".config.js";
export declare const loadConfig: (entrypoint: string, context: string | undefined, target: string) => any;

@@ -7,3 +7,3 @@ import fs from 'fs';

// from https://github.com/webpack/webpack.js.org/issues/1268#issuecomment-313513988
const exec = (code, filename, context) => {
export const exec = (code, filename, context) => {
/* eslint-disable no-underscore-dangle */

@@ -10,0 +10,0 @@ const module = new Module(filename, undefined);

{
"name": "@goji/webpack-plugin",
"version": "0.5.22",
"version": "0.5.23",
"description": "Goji Webpack Plugin",

@@ -40,3 +40,3 @@ "main": "dist/cjs/cjs.js",

"@babel/plugin-proposal-optional-chaining": "^7.8.3",
"@goji/core": "^0.5.22",
"@goji/core": "^0.5.23",
"@types/ejs": "^3.0.0",

@@ -62,2 +62,3 @@ "@types/html-minifier": "^3.5.3",

"ejs": "^3.0.1",
"file-loader": "^5.1.0",
"html-minifier": "^4.0.0",

@@ -89,3 +90,3 @@ "json5": "^2.1.0",

},
"gitHead": "79cac602996b12f5ce8a245c4ae91e63a0d183c9"
"gitHead": "4c384bddc30be26a54dae6ef3c4ce1e64c3bd813"
}
import webpack from 'webpack';
import { GojiBridgeWebpackPlugin } from './plugins/bridge';
import { GojiConfigWebpackPlugin } from './plugins/config';
import { GojiEntryWebpackPlugin } from './plugins/entry';

@@ -28,3 +27,2 @@ import { GojiRuntimePlugin } from './plugins/runtime';

new GojiBridgeWebpackPlugin(options).apply(compiler);
new GojiConfigWebpackPlugin(options).apply(compiler);
new GojiEntryWebpackPlugin(options).apply(compiler);

@@ -31,0 +29,0 @@ new GojiRuntimePlugin(options).apply(compiler);

import webpack from 'webpack';
import path from 'path';
import { unstable_SIMPLIFY_COMPONENTS as SIMPLIFY_COMPONENTS } from '@goji/core';
import { RawSource } from 'webpack-sources';
import deepmerge from 'deepmerge';
import { getWhitelistedComponents, getRenderedComponents } from '../utils/components';

@@ -39,18 +41,17 @@ import { renderTemplate } from '../utils/render';

templatePath: string,
data?: T,
data: T,
merge?: (newSource: string, oldSource: string) => string,
) {
const formattedAssetPath = this.transformExtForPath(assetPath);
// skip existing asset
if (compilation.assets[formattedAssetPath] !== undefined) {
let content = await this.renderTemplate(templatePath, data);
if (!merge && compilation.assets[formattedAssetPath] !== undefined) {
console.warn('skip existing asset', formattedAssetPath);
return;
}
let content = await this.renderTemplate(templatePath, data);
if (merge && compilation.assets[formattedAssetPath]) {
content = merge(content, compilation.assets[formattedAssetPath].source());
}
if (this.options.minimize) {
content = minimize(content, path.extname(assetPath));
}
compilation.assets[formattedAssetPath] = {
source: () => content,
size: () => content.length,
};
compilation.assets[formattedAssetPath] = new RawSource(content);
}

@@ -255,8 +256,15 @@

// generate entry json
await this.renderTemplateToAsset(compilation, `${entrypoint}.json`, 'item.json.ejs', {
useSubtree,
relativePathToBridge: getRelativePathToBridge(entrypoint),
components: this.getWhitelistedComponents(),
useWrappedComponent: this.useWrappedComponent(),
});
await this.renderTemplateToAsset(
compilation,
`${entrypoint}.json`,
'item.json.ejs',
{
useSubtree,
relativePathToBridge: getRelativePathToBridge(entrypoint),
components: this.getWhitelistedComponents(),
useWrappedComponent: this.useWrappedComponent(),
},
(newSource, oldSource) =>
JSON.stringify(deepmerge(JSON.parse(oldSource), JSON.parse(newSource)), null, 2),
);
}

@@ -263,0 +271,0 @@ });

import webpack from 'webpack';
// @ts-ignore
import SingleEntryPlugin from 'webpack/lib/SingleEntryPlugin';
import path from 'path';
import loaderUtils from 'loader-utils';
import replaceExt from 'replace-ext';
import { pathEntriesMap, appEntryMap } from '../shared';

@@ -60,10 +57,13 @@ import { GojiBasedWebpackPlugin } from './based';

const appEntry = 'app';
const pathEntries = readPathsFromAppConfig(this.appConfig);
// remove all ext for entry including `.config.js`
const appEntry = replaceExt(entry.replace(/\.config\.js$/, ''), '');
// add app & pages
for (const pathEntry of [appEntry, ...pathEntries]) {
const request = loaderUtils.urlToRequest(pathEntry);
new SingleEntryPlugin(context, request, pathEntry).apply(compiler);
new webpack.SingleEntryPlugin(
context,
`${require.resolve('../loaders/configFile')}!${request}`,
pathEntry,
).apply(compiler);
}

@@ -70,0 +70,0 @@ // save appEntry and pathEntries for other plugins

@@ -8,3 +8,3 @@ import fs from 'fs';

// from https://github.com/webpack/webpack.js.org/issues/1268#issuecomment-313513988
const exec = (code: string, filename: string, context: string) => {
export const exec = (code: string, filename: string, context: string) => {
/* eslint-disable no-underscore-dangle */

@@ -11,0 +11,0 @@ const module = new Module(filename, undefined);

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

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

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