Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add TypeScript definitions #256

Merged
merged 17 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .neutrinorc.js

This file was deleted.

62 changes: 62 additions & 0 deletions config/tsconfig-build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es2017" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
"module": "es2020" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
// "lib": [], /* Specify library files to be included in the compilation. */
"allowJs": true /* Allow javascript files to be compiled. */,
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true /* Generates corresponding '.d.ts' file. */,
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": false /* Generates corresponding '.map' file. */,
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "../build" /* Redirect output structure to the directory. */,
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
"importHelpers": false /* Import emit helpers from 'tslib'. */,
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

/* Strict Type-Checking Options */
"strict": false /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"strictNullChecks": true /* Enable strict null checks. */,
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */

/* Module Resolution Options */
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": false /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
"inlineSources": false /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */,
"skipLibCheck": true
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
},
"include": ["../src/**/*.js"],
"exclude": []
}
2 changes: 1 addition & 1 deletion cypress.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"baseUrl": "http://localhost:8080",
"baseUrl": "http://127.0.0.1:8000",
"projectId": "f88nv7"
}
36 changes: 18 additions & 18 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
const webpack = require('webpack');
const webpackPreprocessor = require('@cypress/webpack-preprocessor');
const webpackConfig = require('../../webpack.config');
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// const Neutrino = require('neutrino/Neutrino');
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (on) => {
/**
* @type {Cypress.PluginConfig}
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
// const options = webpackPreprocessor.defaultOptions;
// const olProvider = new webpack.ProvidePlugin({ ol: 'openlayers' });
// options.webpackOptions.plugins = [olProvider];

const options = {
// send in the options from your webpack.config.js, so it works the same
// as your app's code
webpackOptions: webpackConfig,
watchOptions: {},
};

on('file:preprocessor', webpackPreprocessor(options));
};
}
26 changes: 7 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@
"description": "OpenLayers Editor",
"version": "2.2.0-beta.10",
"main": "build/index.js",
"dependencies": {},
"peerDependencies": {
"jsts": "^2",
"ol": "^7"
},
"devDependencies": {
"@commitlint/cli": "17.5.1",
"@commitlint/config-conventional": "17.4.4",
"@constgen/neutrino-svg-loader": "1.9.2",
"@cypress/webpack-preprocessor": "5.4.11",
"@neutrinojs/image-loader": "9.5.0",
"@neutrinojs/library": "9.5.0",
"@neutrinojs/style-loader": "9.5.0",
"cypress": "9.2.0",
"esbuild": "0.17.16",
"eslint": "8.38.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "8.8.0",
Expand All @@ -31,22 +28,20 @@
"jsdoc-export-default-interop": "0.3.1",
"jsts": "2.6.1",
"lint-staged": "13.2.1",
"neutrino": "9.5.0",
"ol": "7.3.0",
"prettier": "2.8.7",
"shx": "0.3.4",
"standard-version": "9.5.0",
"start-server-and-test": "1.11.5",
"stylelint": "15.4.0",
"stylelint-config-standard": "32.0.0",
"webpack": "4.44.2",
"webpack-cli": "3.3.12",
"webpack-dev-server": "3.11.0"
"typescript": "5.0.4"
},
"scripts": {
"build": "webpack --mode production ",
"build": "shx rm -rf build && tsc --project config/tsconfig-build.json && esbuild build/index.js --bundle --loader:.svg=dataurl --minify --outfile=build/bundle.js",
"cy:open": "cypress open",
"cy:run": "cypress run --headless",
"cy:test": "yarn build && start-server-and-test start http://localhost:8080 cy:run",
"cy:test": "start-server-and-test start http://127.0.0.1:8000 cy:run",
"doc": "jsdoc -p -r -c jsdoc_conf.json src -d doc README.md",
"format": "prettier --write 'cypress/integration/*.js' 'src/**/*.js' && eslint 'src/**/*.js' --fix && stylelint 'style/**/*.css' 'src/**/*.css' 'src/**/*.scss' --fix",
"lint": "eslint 'cypress/integration/**/*.js' 'src/**/*.js' && stylelint 'style/**/*.css' 'src/**/*.css' 'src/**/*.scss'",
Expand All @@ -56,17 +51,10 @@
"publish:public": "yarn release && yarn build && git push origin HEAD && git push --tags && yarn publish",
"publish:public:dryrun": "yarn release --dry-run",
"release": "standard-version",
"start": "webpack-dev-server --mode development --open",
"start": "esbuild src/index.js --bundle --global-name=ole --loader:.svg=dataurl --minify --outfile=index.js --serve --servedir=. --sourcemap --watch=forever",
friedjoff marked this conversation as resolved.
Show resolved Hide resolved
"test": "jest \"src/.*\\.test\\.js\" --passWithNoTests --env=jsdom --transformIgnorePatterns \"/node_modules/(?!(ol|ol-mapbox-style)/).*/\"",
"test:watch": "yarn test --watchAll"
},
"browserslist": [
">0.2%",
"not dead",
"not op_mini all",
"not ie <= 11",
"not android < 5"
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will leave browserslist, because it's important in mapset .... or maybe not something to test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know how to test this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will test and will addd them again if needed

"eslintConfig": {
"env": {
"cypress/globals": true,
Expand Down
34 changes: 34 additions & 0 deletions tasks/prepare-package.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { readFileSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';

const baseDir = dirname(fileURLToPath(import.meta.url));

function main() {
const pkg = JSON.parse(readFileSync(join(baseDir, '../package.json')));

// write out simplified package.json
pkg.main = 'index.js';
delete pkg.browserslist;
delete pkg.devDependencies;
delete pkg.eslintConfig;
delete pkg['lint-staged'];
delete pkg.prettier;
delete pkg.scripts;
delete pkg.stylelint;
friedjoff marked this conversation as resolved.
Show resolved Hide resolved
const data = JSON.stringify(pkg, null, 2);
writeFileSync(join(baseDir, '../build/package.json'), data);

// copy over license and readme
writeFileSync(
join(baseDir, '../build/LICENSE'),
readFileSync(join(baseDir, '../README.md')),
);

writeFileSync(
join(baseDir, '../build/README.md'),
readFileSync(join(baseDir, '../README.md')),
);
}

main();
4 changes: 0 additions & 4 deletions webpack.config.js

This file was deleted.

Loading