Skip to content

Commit

Permalink
fix: added missing import
Browse files Browse the repository at this point in the history
  • Loading branch information
prisis committed Sep 30, 2024
1 parent e489a25 commit 9c579bb
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 33 deletions.
2 changes: 1 addition & 1 deletion packages/rollup-plugin-styles/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ module.exports = defineConfig({
// Set parserOptions.project for the project to allow TypeScript to create the type-checker behind the scenes when we run linting
parserOptions: {},
rules: {
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-return": "off",
"prefer-template": "off",
},
Expand Down
21 changes: 15 additions & 6 deletions packages/rollup-plugin-styles/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ SOFTWARE.
<!-- DEPENDENCIES -->

# Licenses of bundled dependencies

The published @visulima/rollup-plugin-styles artifact additionally contains code with the following licenses:
MIT

# Bundled dependencies:

## decode-uri-component

License: MIT
By: Sam Verschueren
Repository: SamVerschueren/decode-uri-component
Expand All @@ -42,9 +45,10 @@ Repository: SamVerschueren/decode-uri-component
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------
---

## eventemitter3

License: MIT
By: Arnout Kazemier
Repository: git://github.com/primus/eventemitter3.git
Expand All @@ -71,9 +75,10 @@ Repository: git://github.com/primus/eventemitter3.git
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
---------------------------------------
---

## filter-obj

License: MIT
By: Sindre Sorhus
Repository: sindresorhus/filter-obj
Expand All @@ -88,9 +93,10 @@ Repository: sindresorhus/filter-obj
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------
---

## p-queue

License: MIT
Repository: sindresorhus/p-queue

Expand All @@ -104,9 +110,10 @@ Repository: sindresorhus/p-queue
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------
---

## p-timeout

License: MIT
By: Sindre Sorhus
Repository: sindresorhus/p-timeout
Expand All @@ -121,9 +128,10 @@ Repository: sindresorhus/p-timeout
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------
---

## query-string

License: MIT
By: Sindre Sorhus
Repository: sindresorhus/query-string
Expand All @@ -138,9 +146,10 @@ Repository: sindresorhus/query-string
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---------------------------------------
---

## split-on-first

License: MIT
By: Sindre Sorhus
Repository: sindresorhus/split-on-first
Expand Down
2 changes: 2 additions & 0 deletions packages/rollup-plugin-styles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pnpm add @visulima/rollup-plugin-styles
### PostCSS

Install all the necessary dependencies:

```sh
npm install --save-dev postcss postcss-load-config postcss-modules postcss-modules-extract-imports postcss-modules-local-by-default postcss-modules-scope postcss-modules-values postcss-value-parser icss-utils
```
Expand Down Expand Up @@ -78,3 +79,4 @@ The visulima rollup-plugin-styles is open-sourced software licensed under the [M
[license-url]: LICENSE.md "license"
[npm-image]: https://img.shields.io/npm/v/@visulima/rollup-plugin-styles/latest.svg?style=for-the-badge&logo=npm
[npm-url]: https://www.npmjs.com/package/@visulima/rollup-plugin-styles/v/latest "npm"
```
4 changes: 2 additions & 2 deletions packages/rollup-plugin-styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,12 @@
"@visulima/fs": "2.2.0",
"@visulima/path": "1.0.9",
"cssnano": "7.0.6",
"mime-types": "2.1.35",
"resolve": "2.0.0-next.5",
"resolve.exports": "2.0.2",
"mime-types": "2.1.35",
"source-map-js": "1.2.1"
},
"devDependencies": {
"@types/resolve": "^1.20.6",
"@anolilab/eslint-config": "^15.0.3",
"@anolilab/prettier-config": "^5.0.14",
"@anolilab/semantic-release-pnpm": "1.1.3",
Expand All @@ -142,6 +141,7 @@
"@types/mime-types": "^2.1.4",
"@types/node": "18.19.54",
"@types/node-sass": "^4.11.7",
"@types/resolve": "^1.20.6",
"@types/stylus": "^0.48.43",
"@types/uglifycss": "^0.0.11",
"@visulima/packem": "^1.0.5",
Expand Down
9 changes: 1 addition & 8 deletions packages/rollup-plugin-styles/packem.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ import transformer from "@visulima/packem/transformer/esbuild";
export default defineConfig({
cjsInterop: true,
declaration: false,
externals: [
"stylus",
"less",
"sass",
"node-sass",
"postcss",
"rollup",
],
externals: ["stylus", "less", "sass", "node-sass", "postcss", "rollup"],
fileCache: false,
rollup: {
license: {
Expand Down
2 changes: 1 addition & 1 deletion packages/rollup-plugin-styles/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export default (options: Options = {}): Plugin => {
});

res.css = resMin.css;
res.map = resMin.map?.toString();
res.map = resMin.map.toString();
}

const cssFile = { fileName: res.name, name: res.name, source: res.css, type: "asset" as const };
Expand Down
6 changes: 3 additions & 3 deletions packages/rollup-plugin-styles/src/loaders/less/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ const loader: Loader<LESSLoaderOptions> = {
plugins.push(...options.plugins);
}

const result: Less.RenderOutput = await less.render(code, {
const result: Less.RenderOutput = (await less.render(code, {
...options,
filename: this.id,
plugins,
sourceMap: { outputSourceFiles: true, sourceMapBasepath: path.dirname(this.id) },
}) as Less.RenderOutput;
})) as Less.RenderOutput;

const deps = result.imports;

Expand All @@ -41,7 +41,7 @@ const loader: Loader<LESSLoaderOptions> = {
test: /\.less$/i,
};

// eslint-disable-next-line import/no-unused-modules
export interface LESSLoaderOptions extends Record<string, unknown>, Less.Options {}

export default loader;
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { readFile } from "@visulima/fs";
import { dirname } from "@visulima/path";
import type { ProcessOptions } from "postcss";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { dirname } from "@visulima/path";
import type { AtRule, PluginCreator, Result } from "postcss";
import postcss from "postcss";
import valueParser from "postcss-value-parser";

import { isAbsolutePath, normalizePath } from "../../../utils/path";
import type { ImportResolve } from "./resolve";
import resolveDefault from "./resolve";
import { dirname } from "@visulima/path";

const name = "styles-import";
const extensionsDefault = [".css", ".pcss", ".postcss", ".sss"];
Expand Down
20 changes: 11 additions & 9 deletions packages/rollup-plugin-styles/src/loaders/postcss/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { fileURLToPath } from "node:url";

import { makeLegalIdentifier } from "@rollup/pluginutils";
import { isAccessibleSync, writeFileSync } from "@visulima/fs";
import { dirname, join } from "@visulima/path";
import { basename, dirname, join } from "@visulima/path";
import cssnano from "cssnano";
import type { AcceptedPlugin, ProcessOptions } from "postcss";
import postcss from "postcss";
Expand All @@ -29,17 +29,17 @@ const testing = process.env.NODE_ENV === "test";
const cssVariableName = "css";
const reservedWords = new Set([cssVariableName]);

function getClassNameDefault(name: string): string {
const getClassNameDefault = (name: string): string => {
const id = makeLegalIdentifier(name);

if (reservedWords.has(id)) {
return `_${id}`;
}

return id;
}
};

function ensureAutoModules(am: PostCSSLoaderOptions["autoModules"], id: string): boolean {
const ensureAutoModules = (am: PostCSSLoaderOptions["autoModules"], id: string): boolean => {
if (typeof am === "function") {
return am(id);
}
Expand All @@ -49,13 +49,14 @@ function ensureAutoModules(am: PostCSSLoaderOptions["autoModules"], id: string):
}

return am && /\.module\.[A-Za-z]+$/.test(id);
}
};

type PostCSSOptions = Pick<Required<ProcessOptions>, "from" | "map" | "to"> & PostCSSLoaderOptions["postcss"];

const loader: Loader<PostCSSLoaderOptions> = {
alwaysProcess: true,
name: "postcss",
// eslint-disable-next-line sonarjs/cognitive-complexity
async process({ code, extracted, map }) {
const options = { ...this.options };
const config = await loadConfig(this.id, options.config);
Expand Down Expand Up @@ -245,13 +246,14 @@ const loader: Loader<PostCSSLoaderOptions> = {

output.push(defaultExport);

if (options.dts && (isAccessibleSync(this.id))) {
if (options.dts && isAccessibleSync(this.id)) {
if (supportModules)
dts.push(
`interface ModulesExports ${JSON.stringify(modulesExports)}`,

`interface ModulesExports {${Object.keys(modulesExports)
.map((key) => ` '${key}': string;`)
.join("\n")}
}`,
typeof options.inject === "object" && options.inject.treeshakeable ? `interface ModulesExports {inject:()=>void}` : "",

`declare const ${modulesVariableName}: ModulesExports;`,
);

Expand Down
2 changes: 1 addition & 1 deletion packages/rollup-plugin-styles/src/utils/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ export const ensurePCSSPlugins = (plugins: Options["plugins"]): Result["plugins"
}

return ps;
}
};

0 comments on commit 9c579bb

Please sign in to comment.