Skip to content

Commit 80668b6

Browse files
committed
feat: update project
1 parent f690d6a commit 80668b6

26 files changed

+428
-242
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
dist
1+
index.cjs*
2+
index.mjs*
23
node_modules
34
package-lock.json
5+
yarn.lock
46
*.log*
57
*.result.css
68
.*

.rollup.js

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
import pkg from './package.json'
1+
import babel from 'rollup-plugin-babel'
22

33
export default {
4-
...pkg.rollup,
5-
plugins: [patchBabelPluginSyntaxImportMeta(), ...pkg.rollup.plugins.map(plugin => require(plugin)())],
6-
onwarn(warning, warn) {
7-
if (warning.code !== 'UNRESOLVED_IMPORT') warn(warning)
8-
}
4+
input: 'src/index.js',
5+
output: [
6+
{ file: 'index.cjs', format: 'cjs', exports: 'default', sourcemap: true, strict: false },
7+
{ file: 'index.mjs', format: 'esm', sourcemap: true, strict: false }
8+
],
9+
plugins: [
10+
patchBabelPluginSyntaxImportMeta(),
11+
babel({
12+
presets: [
13+
['@babel/env', { modules: false, targets: { node: 8 } }]
14+
]
15+
})
16+
]
917
}
1018

1119
function patchBabelPluginSyntaxImportMeta () {

.tape.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ module.exports = {
7171
source: 'import-normalize.css',
7272
expect: 'import-normalize.expect.css',
7373
plugin: (() => {
74-
const postcss = require('postcss');
75-
const postcssImport = require('postcss-import');
76-
const postcssNormalize = require('.');
74+
const postcss = require('postcss')
75+
const postcssImport = require('postcss-import')
76+
const postcssNormalize = require('.')
7777

78-
const plugin = postcss([ postcssImport(postcssNormalize().postcssImport()) ]);
78+
const plugin = postcss([ postcssImport(postcssNormalize().postcssImport()) ])
7979

80-
return plugin;
80+
return plugin
8181
})()
8282
}
83-
};
83+
}

.travis.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,4 @@ os:
88
- osx
99

1010
node_js:
11-
- 10
12-
13-
install:
14-
- npm install --ignore-scripts
11+
- 12

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# PostCSS Normalize [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS" width="90" height="90" align="right">][postcss]
22

33
[<img alt="npm version" src="https://img.shields.io/npm/v/postcss-normalize.svg" height="20">][npm-url]
4-
[<img alt="build status" src="https://img.shields.io/travis/csstools/postcss-normalize/master.svg" height="20">][cli-url]
4+
[<img alt="build status" src="https://img.shields.io/travis/csstools/postcss-normalize/main.svg" height="20">][cli-url]
55
[<img alt="support chat" src="https://img.shields.io/badge/support-chat-blue.svg" height="20">][git-url]
66

77
[PostCSS Normalize] lets you use the parts of [normalize.css] or [sanitize.css]
@@ -189,7 +189,7 @@ configure either with the following combinations:
189189
@import "sanitize/*"; /* also, @import "sanitize.css/*" (sanitize + all additions) */
190190
```
191191

192-
[cli-img]: https://img.shields.io/travis/csstools/postcss-normalize/master.svg
192+
[cli-img]: https://img.shields.io/travis/csstools/postcss-normalize/main.svg
193193
[cli-url]: https://travis-ci.org/csstools/postcss-normalize
194194
[git-img]: https://img.shields.io/badge/support-chat-blue.svg
195195
[git-url]: https://gitter.im/postcss/postcss

package.json

+41-46
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,46 @@
77
"repository": "csstools/postcss-normalize",
88
"homepage": "https://github.com/csstools/postcss-normalize#readme",
99
"bugs": "https://github.com/csstools/postcss-normalize/issues",
10-
"main": "dist/index.cjs.js",
11-
"module": "dist/index.esm.mjs",
10+
"main": "index.cjs",
11+
"module": "index.mjs",
1212
"files": [
13-
"dist"
13+
"index.cjs",
14+
"index.cjs.map",
15+
"index.mjs",
16+
"index.mjs.map"
1417
],
1518
"scripts": {
16-
"build": "npx rollup -c .rollup.js",
17-
"build:watch": "npx rollup -c .rollup.js --watch",
18-
"lint": "npx eslint --cache src",
19-
"lint:fix": "npx eslint --cache --fix",
20-
"pretest": "npm install && npm run build",
21-
"test": "npm run lint && npm run tape",
22-
"tape": "npx postcss-tape"
19+
"prepublishOnly": "npm test",
20+
"build": "rollup --config .rollup.js --silent",
21+
"lint": "eslint --cache .gitignore --quiet",
22+
"test": "npm run lint && npm run build && npm run tape",
23+
"tape": "postcss-tape"
2324
},
2425
"engines": {
25-
"node": ">=10.0.0"
26+
"node": ">= 12"
27+
},
28+
"peerDependencies": {
29+
"browserslist": ">= 4",
30+
"postcss": ">= 8"
2631
},
2732
"dependencies": {
28-
"@csstools/normalize.css": "10.1.0",
29-
"postcss-browser-comments": "^3.0.0",
30-
"sanitize.css": "11.0.0"
33+
"@csstools/normalize.css": "*",
34+
"postcss-browser-comments": "^4",
35+
"sanitize.css": "*"
3136
},
3237
"devDependencies": {
33-
"@babel/core": "^7.9.0",
34-
"@babel/plugin-syntax-import-meta": "^7.8.3",
35-
"@babel/preset-env": "^7.9.5",
36-
"babel-eslint": "^10.1.0",
37-
"browserslist": "^4.16.3",
38-
"eslint": "^6.8.0",
39-
"postcss": "^8.2.8",
40-
"postcss-import": "^12.0.1",
38+
"@babel/core": "^7.13.16",
39+
"@babel/plugin-syntax-import-meta": "^7.10.4",
40+
"@babel/preset-env": "^7.13.15",
41+
"browserslist": "^4.16.5",
42+
"eslint": "^7.25.0",
43+
"postcss": "^8.2.13",
44+
"postcss-import": "^14.0.1",
4145
"postcss-tape": "^6.0.1",
4246
"pre-commit": "^1.2.2",
43-
"rollup": "^2.6.0",
47+
"rollup": "^2.46.0",
4448
"rollup-plugin-babel": "^4.4.0"
4549
},
46-
"peerDependencies": {
47-
"browserslist": "^4.16.3",
48-
"postcss": "^8.2.8"
49-
},
5050
"babel": {
5151
"plugins": [
5252
"@babel/plugin-syntax-import-meta"
@@ -61,28 +61,23 @@
6161
]
6262
},
6363
"eslintConfig": {
64-
"env": {
65-
"es6": true,
66-
"node": true
67-
},
6864
"extends": "eslint:recommended",
69-
"parser": "babel-eslint"
70-
},
71-
"rollup": {
72-
"input": "src/index.js",
73-
"plugins": [
74-
"rollup-plugin-babel"
65+
"ignorePatterns": [
66+
".tape.js"
7567
],
76-
"output": [
77-
{
78-
"file": "dist/index.cjs.js",
79-
"format": "cjs"
80-
},
81-
{
82-
"file": "dist/index.esm.js",
83-
"format": "esm"
68+
"parserOptions": {
69+
"ecmaVersion": 12,
70+
"sourceType": "module",
71+
"ecmaFeatures": {
72+
"modules": true
8473
}
85-
]
74+
},
75+
"rules": {
76+
"semi": [
77+
"error",
78+
"never"
79+
]
80+
}
8681
},
8782
"keywords": [
8883
"postcss",

src/index.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { create } from './lib/util';
2-
import postcssBrowserComments from 'postcss-browser-comments';
3-
import postcssImportNormalize from './lib/postcssImportNormalize';
4-
import postcssNormalize from './lib/postcssNormalize';
1+
import { create } from './lib/util'
2+
import postcssBrowserComments from 'postcss-browser-comments'
3+
import postcssImportNormalize from './lib/postcssImportNormalize'
4+
import postcssNormalize from './lib/postcssNormalize'
55

66
const plugin = opts => {
7-
opts = create(opts);
7+
opts = create(opts)
88

9-
const commentsTransformer = postcssBrowserComments(opts).Once;
10-
const normalizeTransformer = postcssNormalize(commentsTransformer, opts);
11-
const postcssImportConfig = postcssImportNormalize(commentsTransformer, opts);
9+
const commentsTransformer = postcssBrowserComments(opts).Once
10+
const normalizeTransformer = postcssNormalize(commentsTransformer, opts)
11+
const postcssImportConfig = postcssImportNormalize(commentsTransformer, opts)
1212

1313
return {
1414
postcssPlugin: 'postcss-normalize',
@@ -19,6 +19,6 @@ const plugin = opts => {
1919
}
2020
}
2121

22-
plugin.postcss = true;
22+
plugin.postcss = true
2323

24-
export default plugin;
24+
export default plugin

src/lib/cssMap.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { create } from './util';
2-
import Module from 'module';
3-
import path from 'path';
4-
import { URL } from 'url';
1+
import { create } from './util'
2+
import Module from 'module'
3+
import path from 'path'
4+
import { URL } from 'url'
55

66
// get esm-compatible script metadata
7-
const currentURL = import.meta.url;
8-
const currentFilename = new URL(currentURL).pathname;
9-
const currentDirname = path.dirname(currentFilename);
7+
const currentURL = import.meta.url
8+
const currentFilename = new URL(currentURL).pathname
9+
const currentDirname = path.dirname(currentFilename)
1010

1111
// get resolved filenames for css libraries
12-
const normalizeCSS = resolve('@csstools/normalize.css');
13-
const normalizeOpinionatedCSS = resolve('@csstools/normalize.css/opinionated.css');
14-
const sanitizeCSS = resolve('sanitize.css');
15-
const sanitizeFormsCSS = resolve('sanitize.css/forms.css');
16-
const sanitizePageCSS = resolve('sanitize.css/page.css');
17-
const sanitizeTypographyCSS = resolve('sanitize.css/typography.css');
12+
const normalizeCSS = resolve('@csstools/normalize.css')
13+
const normalizeOpinionatedCSS = resolve('@csstools/normalize.css/opinionated.css')
14+
const sanitizeCSS = resolve('sanitize.css')
15+
const sanitizeFormsCSS = resolve('sanitize.css/forms.css')
16+
const sanitizePageCSS = resolve('sanitize.css/page.css')
17+
const sanitizeTypographyCSS = resolve('sanitize.css/typography.css')
1818

1919
// export a hashmap of css library filenames
2020
export const parsableFilenames = create({
@@ -24,7 +24,7 @@ export const parsableFilenames = create({
2424
[sanitizeFormsCSS]: true,
2525
[sanitizePageCSS]: true,
2626
[sanitizeTypographyCSS]: true
27-
});
27+
})
2828

2929
// export a hashmap of css library filenames by id
3030
export const resolvedFilenamesById = create({
@@ -36,13 +36,13 @@ export const resolvedFilenamesById = create({
3636
'sanitize/page': [sanitizeCSS, sanitizePageCSS],
3737
'sanitize/typography': [sanitizeCSS, sanitizeTypographyCSS],
3838
'sanitize/*': [sanitizeCSS, sanitizeFormsCSS, sanitizePageCSS, sanitizeTypographyCSS]
39-
});
39+
})
4040

4141
// get the resolved filename of a package/module
4242
function resolve (id) {
4343
return resolve[id] = resolve[id] || Module._resolveFilename(id, {
4444
id: currentFilename,
4545
filename: currentFilename,
4646
paths: Module._nodeModulePaths(currentDirname)
47-
});
47+
})
4848
}

src/lib/parse.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { create } from './util';
2-
import readFile from './readFile';
3-
import postcss from 'postcss';
1+
import { create } from './util'
2+
import readFile from './readFile'
3+
import postcss from 'postcss'
44

5-
const cache = create(null);
5+
const cache = create(null)
66

77
export default (filename, transformer) => readFile(filename).then(
88
// cache the parsed css root
@@ -18,4 +18,4 @@ export default (filename, transformer) => readFile(filename).then(
1818
// resolve the cloned root
1919
() => clone
2020
)
21-
);
21+
)

src/lib/postcssImportNormalize.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { create } from './util';
2-
import { parsableFilenames, resolvedFilenamesById } from './cssMap';
3-
import parse from './parse';
4-
import readFile from './readFile';
1+
import { create } from './util'
2+
import { parsableFilenames, resolvedFilenamesById } from './cssMap'
3+
import parse from './parse'
4+
import readFile from './readFile'
55

66
export default commentsTransformer => opts => {
7-
opts = create(opts);
7+
opts = create(opts)
88

99
// return an postcss-import configuration
1010
return create({
@@ -18,11 +18,11 @@ export default commentsTransformer => opts => {
1818
// otherwise, use the override loader
1919
? opts.load.call(null, filename, importOptions)
2020
// otherwise, return the (conservatively cached) contents of the file
21-
: readFile(filename);
21+
: readFile(filename)
2222
},
2323
resolve (id, basedir, importOptions) {
2424
// get the css id by removing css extensions
25-
const cssId = id.replace(cssExtRegExp, '');
25+
const cssId = id.replace(cssExtRegExp, '')
2626

2727
return cssId in resolvedFilenamesById
2828
// return the known resolved path for the css id
@@ -31,9 +31,9 @@ export default commentsTransformer => opts => {
3131
// otherwise, use the override resolver
3232
? opts.resolve.call(null, id, basedir, importOptions)
3333
// otherwise, return the id to be resolved by postcss-import
34-
: id;
34+
: id
3535
}
36-
});
37-
};
36+
})
37+
}
3838

39-
const cssExtRegExp = /\.css\b/g;
39+
const cssExtRegExp = /\.css\b/g

0 commit comments

Comments
 (0)