Skip to content

Commit

Permalink
v 5.0.1-beta.0
Browse files Browse the repository at this point in the history
* Upgrade rollup stuff
* Fix output
  • Loading branch information
KikoCosmetics committed May 27, 2024
1 parent a0db172 commit 34172e8
Show file tree
Hide file tree
Showing 6 changed files with 286 additions and 253 deletions.
1 change: 1 addition & 0 deletions .idx/dev.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# Use https://search.nixos.org/packages to find packages
packages = [
pkgs.yarn
# pkgs.go
# pkgs.python311
# pkgs.python311Packages.pip
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ Jetbrains is now supporting this library with an open-source license, which will

![jetbrains-logo](https://user-images.githubusercontent.com/5957244/150580991-863d6fba-1090-4924-b26c-be19c6310f24.svg)

---

Thanks to [fire332](https://github.com/fire332) for providing valid input to solve the package cjs/esm problems.

## Development

Pleas, read the CONTRIBUTING.md you can find in the master branch.
Expand Down
32 changes: 17 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-luxon",
"version": "5.0.0",
"version": "5.0.1-beta.0",
"license": "MIT",
"description": "Typescript version of the \"Immutable date wrapper\"",
"author": "Tony Samperi",
Expand All @@ -13,11 +13,13 @@
"homepage": "https://tonysamperi.github.io/ts-luxon/",
"main": "dist/ts-luxon.umd.js",
"typings": "dist/index.d.ts",
"type": "commonjs",
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/ts-luxon.es6.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"import": "./dist/ts-luxon.es6.mjs",
"default": "./dist/ts-luxon.umd.js"
}
},
Expand All @@ -30,38 +32,38 @@
},
"scripts": {
"prepublishOnly": "node ./test/test-dist.js",
"build:watch": "rollup -c rollup.config.js -w",
"build": "rollup -c rollup.config.js",
"build:watch": "rollup -c rollup.config.js --bundleConfigAsCjs -w",
"build": "rollup -c rollup.config.js --bundleConfigAsCjs",
"jest": "jest",
"test": "jest --coverage",
"lint": "tslint --project tsconfig.json",
"lint": "eslint ./src --ext .ts",
"typedoc": "typedoc src/index.ts --excludePrivate --excludeProtected --out dist/api-docs ",
"benchmark": "ts-node benchmarks/index.ts",
"codecov": "codecov",
"check-doc-coverage": "grep '\"coverage\": \"100%\"' dist/docs/coverage.json",
"publish:beta": "npm publish --tag beta"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.8",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-typescript": "^11.0.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@types/benchmark": "^2.1.0",
"@types/jest": "^29.5.4",
"@types/node": "^20.0.0",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"benchmark": "^2.0.0",
"codecov": "^3.0.0",
"documentation": "^14.0.0",
"eslint": "^8.47.0",
"jest": "^29.6.4",
"rollup": "~2.33.3",
"rollup": "^3.0.0",
"rollup-plugin-cleaner": "^1.0.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "~0.6.3",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "~0.29.0",
"rollup-plugin-uglify": "^6.0.4",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-dts": "^6.1.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"tslib": "^2.0.0",
Expand Down
35 changes: 23 additions & 12 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import sourceMaps from "rollup-plugin-sourcemaps";
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from "@rollup/plugin-typescript";
import cleaner from "rollup-plugin-cleaner";
import { uglify } from "rollup-plugin-uglify";
import { terser } from "rollup-plugin-terser";
import terser from "@rollup/plugin-terser";
import pluginReplace from "@rollup/plugin-replace";
import { copyFile } from "fs/promises";

const pkg = require("./package.json");

export default {
input: "src/index.ts",
output: [
{ file: pkg.main, name: "tsLuxon", format: "umd", sourcemap: true },
{ file: pkg.main.replace(".js", ".min.js"), name: "tsLuxon", format: "umd", sourcemap: "inline", plugins: [uglify()] },
{ file: pkg.exports["."].import, format: "es", sourcemap: true },
{ file: pkg.exports["."].import.replace(".mjs", ".min.mjs"), format: "es", sourcemap: "inline", plugins: [uglify()] }
{ file: pkg.main.replace(".js", ".min.js"), name: "tsLuxon", format: "umd", sourcemap: "inline", plugins: [terser()] },
{ file: pkg.exports.import.default, format: "es", sourcemap: true },
{ file: pkg.exports.import.default.replace(".mjs", ".min.mjs"), format: "es", sourcemap: "inline", plugins: [terser()] }
],
external: [],
watch: {
Expand All @@ -38,14 +37,26 @@ export default {
// Allow node_modules resolution, so you can use 'external' to control
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
resolve(),
// Resolve source maps to the original source
sourceMaps(),
nodeResolve(),
pluginReplace({
preventAssignment: !0,
values: {
__BUILD_VRS__: () => pkg.version
}
})
}),
copyAndRename("dist/index.d.ts", "dist/index.d.mts"),
]
};

function copyAndRename(src, dest) {
console.info("copyAndRename", { src, dest })
return {
name: "copy-and-rename",
writeBundle() {
copyFile(src, dest)
.catch((err) => {
console.error("copyAndRename: error copying file!", err);
});
}
};
}
3 changes: 2 additions & 1 deletion src/impl/tokenParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ export class TokenParser {
disqualifyingUnit: { invalidReason: string };
handlers: UnitParser[];
regex: RegExp;
tokens: Array<FormatToken | TokenForPart> = expandMacroTokens(Formatter.parseFormat(this.format), this.locale);
tokens: Array<FormatToken | TokenForPart>;
units: UnitParser[];

constructor(public locale: Locale, public format: string) {
Expand Down Expand Up @@ -514,6 +514,7 @@ export class TokenParser {
}

private _mapTokens(): void {
this.tokens = expandMacroTokens(Formatter.parseFormat(this.format), this.locale);
const units = this.tokens.map((t) => unitForToken(t, this.locale));
this.disqualifyingUnit = units.find((t) => (t as InvalidUnitParser).invalidReason) as {
invalidReason: string
Expand Down
Loading

0 comments on commit 34172e8

Please sign in to comment.