Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These are supported funding model platforms

github: ["joeldenning"]
github: ["jolyndenning"]
patreon: singlespa
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
const webpack = require("webpack");
const RuntimeModule = require("webpack/lib/RuntimeModule");
const Template = require("webpack/lib/Template");
const { RuntimeGlobals } = require("webpack");
const { MODULE_TYPE } = require("mini-css-extract-plugin/dist/utils");
import webpack from "webpack/lib/index.js";
import RuntimeModule from "webpack/lib/RuntimeModule.js";
import RuntimeGlobals from "webpack/lib/RuntimeGlobals.js";
import Template from "webpack/lib/Template.js";
import { MODULE_TYPE } from "mini-css-extract-plugin/dist/utils.js";

/** @typedef {import("webpack").Compiler} Compiler */
const pluginName = "SingleSpaExposeRuntimeCssAssetsPlugin";

class ExposedCssRuntimeModule extends RuntimeModule {
constructor() {
constructor(foundCssModule) {
super("exposed-css-runtime", 10);
this.foundCssModule = foundCssModule;
}
generate() {
return Template.asString(
`${RuntimeGlobals.require}.cssAssets = ${JSON.stringify([
this.chunk.id,
])};`,
`${RuntimeGlobals.require}.cssAssets = ${JSON.stringify(
[this.foundCssModule && this.chunk.id].filter(Boolean),
)};`,
);
}
}

module.exports = class ExposeRuntimeCssAssetsPlugin {
export default class ExposeRuntimeCssAssetsPlugin {
constructor(options) {
this.options = options;
}
Expand Down Expand Up @@ -107,14 +108,15 @@ module.exports = class ExposeRuntimeCssAssetsPlugin {
true,
),
);
compilation.addRuntimeModule(
chunk,
new ExposedCssRuntimeModule(),
);
}

compilation.addRuntimeModule(
chunk,
new ExposedCssRuntimeModule(foundCssModule),
);
}
});
});
});
}
};
}
20 changes: 16 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
"version": "3.0.1",
"description": "Lifecycle helpers for loading CSS",
"type": "module",
"main": "lib/esm/single-spa-css.min.js",
"types": "lib/esm/single-spa-css.d.ts",
"exports": {
".": {
"import": "./lib/esm/single-spa-css.min.js",
"require": "./lib/umd/single-spa-css",
"types": "./lib/esm/single-spa-css.d.ts"
},
"./ExposeRuntimeCssAssetsPlugin": "./ExposeRuntimeCssAssetsPlugin.js"
},
"scripts": {
"test": "jest",
"clean": "rimraf lib",
Expand All @@ -24,7 +30,7 @@
"type": "git",
"url": "git+https://github.com/single-spa/single-spa-css.git"
},
"author": "Joel Denning",
"author": "Jolyn Denning",
"license": "MIT",
"bugs": {
"url": "https://github.com/single-spa/single-spa-css/issues"
Expand All @@ -34,6 +40,8 @@
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/preset-typescript": "^7.12.7",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.26.0",
"@rollup/plugin-typescript": "^12.1.2",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
Expand All @@ -59,5 +67,9 @@
"dependencies": {
"@types/webpack-env": "^1.16.0"
},
"packageManager": "pnpm@9.15.4"
"peerDependencies": {
"mini-css-extract-plugin": "*",
"webpack": "*"
},
"packageManager": "pnpm@10.10.0"
}
Loading