Skip to content

Commit 0b664c1

Browse files
committed
Consider modules version
1 parent 27d039c commit 0b664c1

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,25 @@
1616
},
1717
"scripts": {
1818
"prebuild": "rm -rf dist/",
19-
"build": "tsc",
19+
"build": "npm run build:cjs && npm run build:esm",
20+
"build:cjs": "tsc --module commonjs --target es6 --outDir dist --declaration true",
21+
"build:esm": "tsc --module esnext --target esnext --outDir dist/esm && node tasks/parser.js && rm -rf dist/esm/",
2022
"dev": "npm run build -- -w",
2123
"lint": "eslint --ext .ts --fix ./src",
2224
"format": "prettier --write --loglevel warn ./{src,test}",
2325
"test": "jest",
2426
"prepublishOnly": "npm run test && npm run build"
2527
},
2628
"license": "MIT",
27-
"main": "dist/index.js",
28-
"types": "dist/index.d.ts",
29+
"main": "./dist/index.js",
30+
"module": "./dist/index.mjs",
31+
"types": "./dist/index.d.ts",
32+
"exports": {
33+
".": {
34+
"import": "./dist/index.mjs",
35+
"require": "./dist/index.js"
36+
}
37+
},
2938
"directories": {
3039
"example": "example"
3140
},

test/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const svelte = require('svelte/compiler');
2-
const cssModules = require('../dist/index.js');
2+
const cssModules = require('../');
33

44
module.exports = async ({ source }, options) => {
55
const { code } = await svelte.preprocess(source, [cssModules(options)], {

tsconfig.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
{
22
"compilerOptions": {
3-
"module": "commonjs",
3+
"allowJs": true,
4+
"allowSyntheticDefaultImports": true,
45
"esModuleInterop": true,
5-
"target": "es6",
6-
"lib": [
7-
"esnext"
8-
],
96
"noImplicitAny": true,
107
"moduleResolution": "node",
118
"removeComments": true,
129
"sourceMap": false,
13-
"declaration": true,
14-
"outDir": "dist",
10+
"strict": true,
1511
"baseUrl": ".",
1612
"resolveJsonModule": true,
17-
"paths": {},
13+
"lib": [
14+
"esnext"
15+
],
1816
"typeRoots": [
1917
"./src/types",
2018
"./node_modules/@types",

0 commit comments

Comments
 (0)