Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Updated to support v0 schema
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Oct 12, 2021
1 parent 8e9061b commit fcc5b31
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Piral Webpack Tools Changelog

## 0.8.0 (September 12, 2021)

* Updated dependencies
* Support for v0 schema in `pilet-webpack-plugin`

## 0.7.0 (September 15, 2021)

* Updated dependencies
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.7.0"
"version": "0.8.0"
}
2 changes: 1 addition & 1 deletion packages/html5-entry-webpack-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html5-entry-webpack-plugin",
"version": "0.7.0",
"version": "0.8.0",
"description": "Webpack plugin for allowing HTML files as entry modules.",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/parcel-codegen-loader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parcel-codegen-loader",
"version": "0.7.0",
"version": "0.8.0",
"description": "A loader for .codegen files to auto-generate modules on the fly.",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/pilet-webpack-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pilet-webpack-plugin",
"version": "0.7.0",
"version": "0.8.0",
"description": "Webpack plugin for generating a valid pilet bundle.",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
32 changes: 31 additions & 1 deletion packages/pilet-webpack-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,35 @@ export class PiletWebpackPlugin implements Plugin {
return plugins;
}

piletV0WebpackConfigEnhancer(compiler: Compiler) {
const { name } = this.options;
const config = compiler.options;
const shortName = name.replace(/\W/gi, '');
const prName = `wp4Chunkpr_${shortName}`;
const [mainEntry] = Object.keys(config.entry);

setEnvironment(this.variables);
withExternals(config, this.externals);

const plugins = [
new DefinePlugin(getDefineVariables(this.variables)),
new BannerPlugin({
banner: `//@pilet v:0`,
entryOnly: true,
include: `${mainEntry}.js`,
raw: true,
}),
];

compiler.hooks.afterEnvironment.tap(pluginName, () => {
config.output.jsonpFunction = `${prName}`;
config.output.library = name;
config.output.libraryTarget = 'umd';
});

return plugins;
}

piletV1WebpackConfigEnhancer(compiler: Compiler) {
const { name } = this.options;
const config = compiler.options;
Expand Down Expand Up @@ -101,11 +130,12 @@ export class PiletWebpackPlugin implements Plugin {
this.externals = externals;

switch (schema) {
case 'v0':
return this.piletV0WebpackConfigEnhancer(compiler);
case 'v1':
return this.piletV1WebpackConfigEnhancer(compiler);
case 'v2':
return this.piletV2WebpackConfigEnhancer(compiler);
case 'v0':
case 'none':
default:
return this.piletVxWebpackConfigEnhancer(compiler);
Expand Down
2 changes: 1 addition & 1 deletion packages/piral-instance-webpack-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "piral-instance-webpack-plugin",
"version": "0.7.0",
"version": "0.8.0",
"description": "Webpack plugin for generating a valid Piral instance bundle.",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down

0 comments on commit fcc5b31

Please sign in to comment.