Skip to content

Commit

Permalink
Merge pull request #12 from Nosto/CFE-80-dependency-handling-improvem…
Browse files Browse the repository at this point in the history
…ents

CFE-80: Dependency handling improvements
  • Loading branch information
rokbar-nosto authored Dec 12, 2023
2 parents 795f652 + ec39197 commit a73b7f8
Show file tree
Hide file tree
Showing 9 changed files with 14,329 additions and 24,534 deletions.
38,356 changes: 13,994 additions & 24,362 deletions package-lock.json

Large diffs are not rendered by default.

323 changes: 177 additions & 146 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,155 +1,186 @@
{
"name": "@nosto/nosto-autocomplete",
"version": "1.0.0",
"description": "Library designed to simplify the implementation of search autocomplete functionality",
"keywords": [
"nosto"
],
"homepage": "https://github.com/Nosto/nosto-autocomplete#readme",
"bugs": {
"url": "https://github.com/Nosto/nosto-autocomplete/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Nosto/nosto-autocomplete.git"
},
"license": "BSD-3-Clause",
"author": "Nosto",
"type": "module",
"main": "./dist/nosto-autocomplete.cjs",
"unpkg": "./dist/nosto-autocomplete.umd.js",
"module": "./dist/nosto-autocomplete.module.js",
"source": "./src/entries/base.ts",
"types": "./dist/nosto-autocomplete.d.ts",
"exports": {
".": {
"browser": "./dist/nosto-autocomplete.module.js",
"umd": "./dist/nosto-autocomplete.umd.js",
"import": "./dist/nosto-autocomplete.mjs",
"require": "./dist/nosto-autocomplete.js"
"name": "@nosto/nosto-autocomplete",
"version": "1.0.0",
"description": "Library designed to simplify the implementation of search autocomplete functionality",
"keywords": [
"nosto"
],
"homepage": "https://github.com/Nosto/nosto-autocomplete#readme",
"bugs": {
"url": "https://github.com/Nosto/nosto-autocomplete/issues"
},
"./react": {
"browser": "./dist/react/nosto-autocomplete.module.js",
"umd": "./dist/react/nosto-autocomplete.umd.js",
"import": "./dist/react/nosto-autocomplete.mjs",
"require": "./dist/react/nosto-autocomplete.js"
"repository": {
"type": "git",
"url": "git+https://github.com/Nosto/nosto-autocomplete.git"
},
"./liquid": {
"browser": "./dist/nosto-autocomplete.module.js",
"umd": "./dist/liquid/nosto-autocomplete.umd.js",
"import": "./dist/liquid/nosto-autocomplete.mjs",
"require": "./dist/liquid/nosto-autocomplete.js"
"license": "BSD-3-Clause",
"author": "Nosto",
"main": "dist/nosto-autocomplete.cjs",
"module": "dist/nosto-autocomplete.module.js",
"umd:main": "dist/nosto-autocomplete.umd.js",
"unpkg": "dist/nosto-autocomplete.umd.js",
"source": "src/index.ts",
"exports": {
".": {
"browser": "./dist/nosto-autocomplete.module.js",
"umd": "./dist/nosto-autocomplete.umd.js",
"import": "./dist/nosto-autocomplete.mjs",
"require": "./dist/nosto-autocomplete.cjs",
"types": "./dist/nosto-autocomplete.d.ts"
},
"./liquid": {
"browser": "./dist/nosto-autocomplete.module.js",
"umd": "./dist/liquid/nosto-autocomplete.umd.js",
"import": "./dist/liquid/nosto-autocomplete.mjs",
"require": "./dist/liquid/nosto-autocomplete.cjs",
"types": "./dist/liquid/nosto-autocomplete.d.ts"
},
"./mustache": {
"browser": "./dist/mustache/nosto-autocomplete.module.js",
"umd": "./dist/mustache/nosto-autocomplete.umd.js",
"import": "./dist/mustache/nosto-autocomplete.mjs",
"require": "./dist/mustache/nosto-autocomplete.cjs",
"types": "./dist/mustache/nosto-autocomplete.d.ts"
},
"./styles": {
"import": "./dist/styles.css",
"require": "./dist/styles.css"
},
"./styles.css": {
"import": "./dist/styles.css",
"require": "./dist/styles.css"
},
"./dist/styles.css": {
"import": "./dist/styles.css",
"require": "./dist/styles.css"
}
},
"./mustache": {
"browser": "./dist/mustache/nosto-autocomplete.module.js",
"umd": "./dist/mustache/nosto-autocomplete.umd.js",
"import": "./dist/mustache/nosto-autocomplete.mjs",
"require": "./dist/mustache/nosto-autocomplete.js"
}
},
"files": [
"dist/**/*"
],
"scripts": {
"build": "npm run typecheck && npm run lint && npm run build:liquid && npm run build:mustache && npm run build:base",
"build:base": "microbundle --generateTypes false src/entries/base.ts -o dist && dts-bundle-generator -o dist/nosto-autocomplete.d.ts src/entries/base.ts",
"build:liquid": "microbundle --generateTypes false src/entries/liquid.ts -o dist/liquid && dts-bundle-generator -o dist/liquid/nosto-autocomplete.d.ts src/entries/liquid.ts",
"build:mustache": "microbundle --generateTypes false src/entries/mustache.ts -o dist/mustache && dts-bundle-generator -o dist/mustache/nosto-autocomplete.d.ts src/entries/mustache.ts",
"build:docs": "typedoc src/entries/base.ts",
"build:site": "npm run build:docs && npm run test:cov && rm -rf site && cp -r./docs ./site && cp -r./examples ./site/examples && cp -r./coverage ./site/coverage",
"lint": "eslint 'src/**/*.{ts,tsx}' --cache",
"typecheck": "tsc --noEmit",
"prettify": "node cleanup.js && prettier --write \"{src,spec}/**/*.ts\"",
"test": "jest spec",
"test:cov": "jest --coverage spec && make-coverage-badge",
"codegen": "graphql-codegen",
"dev:docs": "typedoc --watch src/entries/base.ts"
},
"prettier": {
"trailingComma": "es5",
"semi": false,
"arrowParens": "avoid"
},
"release": {
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"main",
"next",
"next-major",
{
"name": "beta",
"prerelease": true
},
{
"name": "alpha",
"prerelease": true
}
"typesVersions": {
"*": {
"liquid": [
"dist/liquid/nosto-autocomplete.d.ts"
],
"mustache": [
"dist/mustache/nosto-autocomplete.d.ts"
]
}
},
"types": "dist/nosto-autocomplete.d.ts",
"files": [
"dist/**/*"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git",
"@semantic-release/github"
]
},
"devDependencies": {
"@graphql-codegen/cli": "5.0.0",
"@graphql-codegen/typescript": "4.0.1",
"@testing-library/dom": "^9.3.1",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/jest": "^29.5.3",
"@types/mustache": "^4.2.4",
"@types/react": "^18.2.33",
"@types/react-dom": "^18.2.14",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"dts-bundle-generator": "^8.0.1",
"eslint": "^8.53.0",
"jest": "^29.6.2",
"jest-environment-jsdom": "^29.6.2",
"make-coverage-badge": "^1.2.0",
"microbundle": "^0.15.1",
"prettier": "^3.0.2",
"ts-jest": "^29.1.1",
"typedoc": "^0.24.8",
"typescript": "^5.1.6"
},
"peerDependencies": {
"liquidjs": "^10.9.4",
"react": "^18.2.0",
"mustache": "^4.2.0"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "jsdom",
"testEnvironmentOptions": {
"resources": "usable",
"runScripts": "dangerously"
"scripts": {
"build": "npm run typecheck && npm run lint && npm run build:liquid && npm run build:mustache && npm run build:base && npm run build:styles",
"build:base": "microbundle --generateTypes false src/entries/base.ts -o dist && dts-bundle-generator -o dist/nosto-autocomplete.d.ts src/entries/base.ts",
"build:liquid": "microbundle --generateTypes false src/entries/liquid.ts -o dist/liquid && dts-bundle-generator -o dist/liquid/nosto-autocomplete.d.ts src/entries/liquid.ts",
"build:mustache": "microbundle --generateTypes false src/entries/mustache.ts -o dist/mustache && dts-bundle-generator -o dist/mustache/nosto-autocomplete.d.ts src/entries/mustache.ts",
"build:styles": "cp src/styles.css dist/styles.css",
"build:docs": "typedoc src/index.ts",
"build:site": "npm run build:docs && npm run test:cov && rm -rf site && cp -r./docs ./site && cp -r./examples ./site/examples && cp -r./coverage ./site/coverage",
"lint": "eslint 'src/**/*.{ts,tsx}' --cache",
"typecheck": "tsc --noEmit",
"prettify": "node cleanup.js && prettier --write \"{src,spec}/**/*.ts\"",
"test": "jest spec",
"test:cov": "jest --coverage spec && make-coverage-badge",
"codegen": "graphql-codegen",
"dev:docs": "typedoc --watch src/index.ts"
},
"prettier": {
"trailingComma": "es5",
"semi": false,
"arrowParens": "avoid"
},
"release": {
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"main",
"next",
"next-major",
{
"name": "beta",
"prerelease": true
},
{
"name": "alpha",
"prerelease": true
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git",
"@semantic-release/github"
]
},
"devDependencies": {
"@graphql-codegen/cli": "5.0.0",
"@graphql-codegen/typescript": "4.0.1",
"@testing-library/dom": "^9.3.1",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/jest": "^29.5.3",
"@types/mustache": "4.x",
"@types/react": "18.x",
"@types/react-dom": "18.x",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"dts-bundle-generator": "^8.0.1",
"eslint": "^8.53.0",
"jest": "^29.6.2",
"jest-environment-jsdom": "^29.6.2",
"liquidjs": "^10.9.4",
"make-coverage-badge": "^1.2.0",
"microbundle": "^0.15.1",
"mustache": "^4.2.0",
"prettier": "^3.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"ts-jest": "^29.1.1",
"typedoc": "^0.24.8",
"typescript": "5.1.x"
},
"peerDependencies": {
"liquidjs": "10.x",
"mustache": "4.x"
},
"peerDependenciesMeta": {
"mustache": {
"optional": true
},
"liquidjs": {
"optional": true
}
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "jsdom",
"testEnvironmentOptions": {
"resources": "usable",
"runScripts": "dangerously"
},
"coverageReporters": [
"clover",
"json",
"json-summary",
"lcov",
"text"
]
},
"coverageReporters": [
"clover",
"json",
"json-summary",
"lcov",
"text"
]
},
"codegen": {
"overwrite": true,
"schema": "https://search.nosto.com/v1/graphql",
"generates": {
"src/api/search/generated.ts": {
"config": {
"enumsAsTypes": true,
"defaultScalarType": "unknown",
"skipTypename": true,
"useImplementingTypes": true,
"declarationKind": "interface"
"codegen": {
"overwrite": true,
"schema": "https://search.nosto.com/v1/graphql",
"generates": {
"src/api/search/generated.ts": {
"config": {
"enumsAsTypes": true,
"defaultScalarType": "unknown",
"skipTypename": true,
"useImplementingTypes": true,
"declarationKind": "interface"
}
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion spec/liquid.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "@testing-library/jest-dom"
import {
fromLiquidTemplate, fromRemoteLiquidTemplate,
} from "../src/entries/liquid"
} from "../src/liquid"
import { handleAutocomplete, hooks, autocompleteSuite } from './suites/autocomplete'
import liquidTemplate from './templates/liquid'
import { waitFor } from '@testing-library/dom'
Expand Down
2 changes: 1 addition & 1 deletion src/entries/liquid.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./base"
export { fromLiquidTemplate, fromRemoteLiquidTemplate } from "../liquid"
export * from './base'
2 changes: 1 addition & 1 deletion src/entries/mustache.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./base"
export { fromMustacheTemplate, fromRemoteMustacheTemplate } from "../mustache"
export * from './base'
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './entries/base'
export * from './entries/mustache'
export * from './entries/liquid'
16 changes: 2 additions & 14 deletions src/liquid.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import { DefaultState } from "./utils/state"
import { AnyPromise } from "./utils/promise"

declare global {
interface Window {
liquidjs?: {
Liquid: {
new(): {
parseAndRenderSync(template: string, state: object): string
}
}
}
}
}
import { Liquid } from "liquidjs"

/**
* Render a liquid template into a container
Expand All @@ -24,8 +13,7 @@ declare global {
export function fromLiquidTemplate<State extends object = DefaultState>(
template: string
): (container: HTMLElement, state: State) => PromiseLike<void> {
const LiquidFactory = window?.liquidjs?.Liquid
const instance = LiquidFactory ? new LiquidFactory() : undefined
const instance = Liquid ? new Liquid() : undefined

if (instance === undefined) {
throw new Error(
Expand Down
Loading

0 comments on commit a73b7f8

Please sign in to comment.