Skip to content

Commit

Permalink
Merge pull request #6 from fink-lang/esm
Browse files Browse the repository at this point in the history
publish esm
  • Loading branch information
kollhof authored Oct 5, 2020
2 parents 1e40158 + f787ff6 commit deb5a8b
Show file tree
Hide file tree
Showing 12 changed files with 2,876 additions and 677 deletions.
3 changes: 3 additions & 0 deletions babel.build-cjs.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
presets: [['@babel/preset-env', {targets: {node: 'current'}}]]
}
11 changes: 8 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@

module.exports = {
export default {
testEnvironment: 'node',
setupFiles: [],
moduleFileExtensions: ['js', 'fnk'],
transform: {
'^.+\\.fnk$': ['@fink/jest/transform']
'^.+\\.fnk$': ['@fink/jest/transform.js'],
'^.+\\.js$': [
'babel-jest',
{presets: [['@babel/preset-env', {targets: {node: 'current'}}]]}
],
},
transformIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/build/'],

snapshotResolver: '@fink/jest/snapshot-resolver',
resolver: '@fink/jest/cjs/module-resolver.js',
snapshotResolver: '@fink/jest/snapshot-resolver.js',

modulePathIgnorePatterns: ['<rootDir>/build/'],

Expand Down
1 change: 1 addition & 0 deletions package-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type": "commonjs"}
3,358 changes: 2,728 additions & 630 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 20 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
"engines": {
"node": ">=14.0.0"
},
"sideEffects": false,
"type": "module",
"exports": {
"./": {
"import": "./",
"require": "./cjs/"
}
},
"private": false,
"publishConfig": {
"access": "public"
Expand All @@ -19,25 +27,29 @@
"default": "run clean test build",
"clean": "rimraf ./build",
"build": "run build:*",
"build:dir": "mkdir -p ./build/pkg/",
"build:fnk": "fnk --src ./src --out-dir build/pkg --ignore './src/**/*.test.fnk'",
"build:js": "cp ./src/globals.js ./src/this.js ./src/reflect.js ./src/nullish.js ./build/pkg/",
"build:dir": "mkdir -p ./build/pkg",
"build:fnk-esm": "cp src/globals.js src/nullish.js src/reflect.js src/this.js ./build/pkg/",
"build:fnk-cjs": "babel --config-file ./babel.build-cjs.config.js --out-dir build/pkg/cjs ./src/*.js",
"build:pkg-cjs": "cp ./package-cjs.json build/pkg/cjs/package.json",
"build:files": "cp ./package.json ./README.md ./LICENSE ./build/pkg/",
"test": "run jest",
"jest": "jest --verbose --runInBand --no-cache ",
"cd": "run clean test build release",
"release": "semantic-release"
},
"devDependencies": {
"@fink/cli": "^6.2.1",
"@fink/jest": "^5.2.1",
"@fink/larix": "^12.2.1",
"@fink/loxia": "^12.2.1",
"@babel/cli": "^7.11.6",
"@babel/preset-env": "^7.11.5",
"@fink/cli": "^7.0.0",
"@fink/jest": "^6.0.0",
"@fink/larix": "^12.3.0",
"@fink/loxia": "^13.0.0",
"babel-jest": "^26.3.0",
"commitizen": "^4.0.5",
"cz-conventional-changelog": "^3.1.0",
"jest-cli": "^26.1.0",
"npx-run": "^2.1.2",
"semantic-release": "^17.1.1"
"semantic-release": "^17.1.2"
},
"config": {
"commitizen": {
Expand Down
87 changes: 86 additions & 1 deletion src/globals.js
Original file line number Diff line number Diff line change
@@ -1 +1,86 @@
module.exports = globalThis;
const Object_ = Object;
export {Object_ as Object};

export const Symbol = /*@__PURE__*/ (()=> globalThis.Symbol)();
export const Boolean = /*@__PURE__*/ (()=> globalThis.Boolean)();
export const Number = /*@__PURE__*/ (()=> globalThis.Number)();
export const BigInt = /*@__PURE__*/ (()=> globalThis.BigInt)();
export const String = /*@__PURE__*/ (()=> globalThis.String)();
export const RegExp = /*@__PURE__*/ (()=> globalThis.RegExp)();
export const Date = /*@__PURE__*/ (()=> globalThis.Date)();
export const Function = /*@__PURE__*/ (()=> globalThis.Function)();

export const NaN = /*@__PURE__*/ (()=> globalThis.NaN)();
export const isNaN = /*@__PURE__*/ (()=> globalThis.isNaN)();
export const isFinite = /*@__PURE__*/ (()=> globalThis.isFinite)();
export const parseFloat = /*@__PURE__*/ (()=> globalThis.parseFloat)();
export const parseInt = /*@__PURE__*/ (()=> globalThis.parseInt)();
export const Infinity = /*@__PURE__*/ (()=> globalThis.Infinity)();

export const Promise = /*@__PURE__*/ (()=> globalThis.Promise)();
export const Generator = /*@__PURE__*/ (()=> globalThis.Generator)();
export const GeneratorFunction = /*@__PURE__*/ (()=> globalThis.GeneratorFunction)();
export const AsyncFunction = /*@__PURE__*/ (()=> globalThis.AsyncFunction)();
export const AsyncGenerator = /*@__PURE__*/ (()=> globalThis.AsyncGenerator)();
export const AsyncGeneratorFunction = /*@__PURE__*/ (()=> globalThis.AsyncGeneratorFunction)();

export const Reflect = /*@__PURE__*/ (()=> globalThis.Reflect)();
export const Proxy = /*@__PURE__*/ (()=> globalThis.Proxy)();

export const Math = /*@__PURE__*/ (()=> globalThis.Math)();

export const Array = /*@__PURE__*/ (()=> globalThis.Array)();
export const Int8Array = /*@__PURE__*/ (()=> globalThis.Int8Array)();
export const Uint8Array = /*@__PURE__*/ (()=> globalThis.Uint8Array)();
export const Uint8ClampedArray = /*@__PURE__*/ (()=> globalThis.Uint8ClampedArray)();
export const Int16Array = /*@__PURE__*/ (()=> globalThis.Int16Array)();
export const Uint16Array = /*@__PURE__*/ (()=> globalThis.Uint16Array)();
export const Int32Array = /*@__PURE__*/ (()=> globalThis.Int32Array)();
export const Uint32Array = /*@__PURE__*/ (()=> globalThis.Uint32Array)();
export const Float32Array = /*@__PURE__*/ (()=> globalThis.Float32Array)();
export const Float64Array = /*@__PURE__*/ (()=> globalThis.Float64Array)();
export const BigInt64Array = /*@__PURE__*/ (()=> globalThis.BigInt64Array)();
export const BigUint64Array = /*@__PURE__*/ (()=> globalThis.BigUint64Array)();

export const Map = /*@__PURE__*/ (()=> globalThis.Map)();
export const Set = /*@__PURE__*/ (()=> globalThis.Set)();
export const WeakMap = /*@__PURE__*/ (()=> globalThis.WeakMap)();
export const WeakSet = /*@__PURE__*/ (()=> globalThis.WeakSet)();

export const ArrayBuffer = /*@__PURE__*/ (()=> globalThis.ArrayBuffer)();
export const SharedArrayBuffer = /*@__PURE__*/ (()=> globalThis.SharedArrayBuffer)();
export const Atomics = /*@__PURE__*/ (()=> globalThis.Atomics)();
export const DataView = /*@__PURE__*/ (()=> globalThis.DataView)();
export const JSON = /*@__PURE__*/ (()=> globalThis.JSON)();

export const Intl = /*@__PURE__*/ (()=> globalThis.Intl)();

export const WebAssembly = /*@__PURE__*/ (()=> globalThis.WebAssembly)();

export const Error = /*@__PURE__*/ (()=> globalThis.Error)();
export const InternalError = /*@__PURE__*/ (()=> globalThis.InternalError)();
export const RangeError = /*@__PURE__*/ (()=> globalThis.RangeError)();
export const ReferenceError = /*@__PURE__*/ (()=> globalThis.ReferenceError)();
export const SyntaxError = /*@__PURE__*/ (()=> globalThis.SyntaxError)();
export const TypeError = /*@__PURE__*/ (()=> globalThis.TypeError)();
export const URIError = /*@__PURE__*/ (()=> globalThis.URIError)();

export const encodeURI = /*@__PURE__*/ (()=> globalThis.encodeURI)();
export const encodeURIComponent = /*@__PURE__*/ (()=> globalThis.encodeURIComponent)();
export const decodeURI = /*@__PURE__*/ (()=> globalThis.decodeURI)();
export const decodeURIComponent = /*@__PURE__*/ (()=> globalThis.decodeURIComponent)();


export const console = /*@__PURE__*/ (()=> globalThis.console)();
export const window = /*@__PURE__*/ (()=> globalThis.window)();
export const document = /*@__PURE__*/ (()=> globalThis.document)();
export const crypto = /*@__PURE__*/ (()=> globalThis.crypto)();
export const fetch = /*@__PURE__*/ (()=> globalThis.fetch)();
export const TextDecoder = /*@__PURE__*/ (()=> globalThis.TextDecoder)();
export const TextEncoder = /*@__PURE__*/ (()=> globalThis.TextEncoder)();
export const setTimeout = /*@__PURE__*/ (()=> globalThis.setTimeout)();
export const setImmediate = /*@__PURE__*/ (()=> globalThis.setImmediate)();
export const setInterval = /*@__PURE__*/ (()=> globalThis.setInterval)();
export const process = /*@__PURE__*/ (()=> globalThis.process)();

export const globals = /*@__PURE__*/ (()=> globalThis)();
4 changes: 2 additions & 2 deletions src/nullish.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
exports.ˆnull = null;
exports.ˆundefined = (void 0);
export const ˆnull = null;
export const ˆundefined = (void 0);
6 changes: 3 additions & 3 deletions src/nullish.test.fnk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{describe, it, expect, to_equal} = import '@fink/jest'
{describe, it, expect, to_equal} = import '@fink/jest/test.fnk'

{null, undefined} = import './nullish'
{JSON} = import './globals'
{null, undefined} = import './nullish.js'
{JSON} = import './globals.js'


describe 'null, undefined', fn:
Expand Down
37 changes: 16 additions & 21 deletions src/reflect.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
export const ˆnew = (cls, ...args)=> Reflect.construct(cls, args);

exports.ˆnew = (cls, ...args)=> Reflect.construct(cls, args);

exports.apply = Reflect.apply;
export const apply = /*@__PURE__*/ (()=> Reflect.apply)();
export const has = /*@__PURE__*/ (()=> Reflect.has)();
export const get = /*@__PURE__*/ (()=> Reflect.get)();
export const set = /*@__PURE__*/ (()=> Reflect.set)();
export const own_keys = /*@__PURE__*/ (()=> Reflect.ownKeys)();
export const delete_property = /*@__PURE__*/ (()=> Reflect.deleteProperty)();
export const define_property = /*@__PURE__*/ (()=> Reflect.defineProperty)();
export const get_own_property_descriptor = /*@__PURE__*/ (()=> Reflect.getOwnPropertyDescriptor)();
export const get_prototype_of = /*@__PURE__*/ (()=> Reflect.getPrototypeOf)();
export const set_prototype_of = /*@__PURE__*/ (()=> Reflect.setPrototypeOf)();
export const is_extensible = /*@__PURE__*/ (()=> Reflect.isExtensible)();
export const prevent_extensions = /*@__PURE__*/ (()=> Reflect.preventExtensions)();

exports.has = Reflect.has;
exports.get = Reflect.get;
exports.set = Reflect.set;
exports.set_props = Object.assign;
export const set_props = /*@__PURE__*/ (()=> Object.assign)();

exports.delete_property = Reflect.deleteProperty;
exports.define_property = Reflect.defineProperty;
export const get_type = /*@__PURE__*/ (obj)=> typeof obj;

exports.own_keys = Reflect.ownKeys;

exports.get_own_property_descriptor = Reflect.getOwnPropertyDescriptor;

exports.get_prototype_of = Reflect.getPrototypeOf;
exports.set_prototype_of = Reflect.setPrototypeOf;

exports.is_extensible = Reflect.isExtensible;
exports.prevent_extensions = Reflect.preventExtensions;

exports.get_type = (obj)=> typeof obj;

exports.is_instance = (obj, cls)=> obj instanceof cls;
export const is_instance = (obj, cls)=> obj instanceof cls;
14 changes: 7 additions & 7 deletions src/reflect.test.fnk
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{describe, it, expect, to_equal} = import '@fink/jest'
{describe, it, expect, to_equal} = import '@fink/jest/test.fnk'

{
new, has, get, set, set_props,
delete_property, define_property, get_own_property_descriptor,
get_prototype_of, set_prototype_of,
is_extensible, prevent_extensions,
new, has, get, set, set_props
delete_property, define_property, get_own_property_descriptor
get_prototype_of, set_prototype_of
is_extensible, prevent_extensions
get_type, is_instance
} = import './reflect'
} = import './reflect.js'

{String, Array} = import './globals'
{String, Array} = import './globals.js'


describe 'reflect', fn:
Expand Down
2 changes: 1 addition & 1 deletion src/this.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
exports.with_this = (fn)=> function with_this(...args) {
export const with_this = (fn)=> function with_this(...args) {
return fn.call(undefined, this, ...args);
}
2 changes: 1 addition & 1 deletion src/this.test.fnk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{describe, it, expect, to_equal} = import '@fink/jest'
{describe, it, expect, to_equal} = import '@fink/jest/test.js'

{apply} = import './reflect'
{with_this} = import './this'
Expand Down

0 comments on commit deb5a8b

Please sign in to comment.