Skip to content

Commit

Permalink
Merge pull request #560 from namecheap/ilc-typescript-support
Browse files Browse the repository at this point in the history
Ilc typescript support
  • Loading branch information
blackrabbit99 authored Nov 21, 2023
2 parents c44c6e4 + 0786814 commit dbd5d26
Show file tree
Hide file tree
Showing 15 changed files with 1,639 additions and 1,102 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Ignore artifacts:
ilc/public
ilc/dist
.nyc_output
.karma_output
1 change: 1 addition & 0 deletions ilc/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/public/*
/.nyc_output
/.karma_output
/dist
2 changes: 1 addition & 1 deletion ilc/.mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"server/**/*.spec.js",
"common/**/*.spec.js"
],
"require": "@babel/register",
"require": "ts-node/register",
"timeout": 5000,
"exclude": "node_modules/**/*"
}
11 changes: 11 additions & 0 deletions ilc/build/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ module.exports = {
mode: 'production',
module: {
rules: [
{
test: /\.(js|ts)$/,
use: {
loader: 'ts-loader',
options: {
configFile: 'tsconfig.client.json',
},
},
exclude: /node_modules/,
},
{ parser: { System: false } },
{
test: /\.js?$/,
Expand All @@ -32,6 +42,7 @@ module.exports = {
alias: {
'single-spa': require.resolve('single-spa/lib/umd/single-spa.min.js'),
},
extensions: ['.js', '.ts'],
plugins: [new ResolveIlcDefaultPluginsWebpackPlugin(ilcPluginsPath)],
},
plugins: [
Expand Down
2 changes: 1 addition & 1 deletion ilc/client/errors/BaseError.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as uuidv4 from 'uuid/v4';
import uuidv4 from 'uuid/v4';

export class BaseError extends Error {
data = {};
Expand Down
2 changes: 1 addition & 1 deletion ilc/client/registry/factory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Registry from './Registry';
import CacheWrapper from '../../common/CacheWrapper';
import * as localStorage from '../../common/localStorage';
import localStorage from '../../common/localStorage';

export default new Registry(new CacheWrapper(localStorage, console));
1 change: 1 addition & 0 deletions ilc/nyc.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
'newrelic.js',
'.karma_output',
'client',
'dist',
'public',
'config',
'build',
Expand Down
2,671 changes: 1,579 additions & 1,092 deletions ilc/package-lock.json

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions ilc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"test:coverage": "cross-env NODE_ENV=test nyc mocha --exit",
"test:client": "npm run build:systemjs && cross-env NODE_ENV=test karma start",
"test:client:watch": "npm run test:client -- --single-run=false --auto-watch=true",
"start": "node --max-http-header-size 30000 server/index.js",
"dev": "npm run build:polyfills && cross-env NODE_ENV=development nodemon --max-http-header-size 30000 server/index.js",
"build": "rimraf public && npm run build:systemjs && npm run build:client && npm run build:polyfills",
"start": "node --max-http-header-size 30000 dist/server/index.js",
"dev": "npm run build:polyfills && cross-env NODE_ENV=development nodemon --max-http-header-size 30000 dist/server/index.js",
"build": "rimraf public && npm run build:server && npm run build:systemjs && npm run build:client && npm run build:polyfills",
"build:server": "npx tsc --project ./tsconfig.server.json && npx copyfiles -f ./config/* ./dist/config/",
"build:client": "webpack --config build/webpack.js --progress",
"build:systemjs": "node ./systemjs/build.js",
"build:polyfills": "mkdir public || true && nwget https://polyfill.io/v3/polyfill.min.js?features=URL%2CObject.entries%2CDocumentFragment.prototype.append%2CElement.prototype.append%2CElement.prototype.remove%2CObject.assign%2CElement.prototype.closest%2CCustomEvent%2CObject.values%2CArray.from -O ./public/polyfill.min.js"
Expand Down Expand Up @@ -65,6 +66,7 @@
"babel-plugin-transform-async-to-promises": "^0.8.18",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"copyfiles": "^2.4.1",
"karma": "^6.4.2",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.2.0",
Expand All @@ -83,6 +85,9 @@
"rimraf": "^5.0.5",
"sinon": "^16.1.0",
"supertest": "^6.3.3",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-dev-middleware": "^6.1.1",
Expand Down
2 changes: 1 addition & 1 deletion ilc/server/GuardManager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('GuardManager', () => {
pluginManager.getTransitionHooksPlugin.returns(transitionHooksPlugin);
transitionHooksPlugin.getTransitionHooks.returns(hooks);

app = createApp(helpers.getRegistryMock(), pluginManager, context);
const app = createApp(helpers.getRegistryMock(), pluginManager, context);

try {
res = await app.inject({ method: 'GET', url: '/all' });
Expand Down
2 changes: 1 addition & 1 deletion ilc/server/plugins/PluginsLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PluginsLoader {

if (environment.isLegacyPluginsDiscoveryEnabled()) {
const pluginPaths = fg.sync(['ilc-plugin-*/package.json', '@*/ilc-plugin-*/package.json'], {
cwd: path.resolve(__dirname, '../node_modules'),
cwd: path.resolve(__dirname, '../../node_modules'),
absolute: true,
});

Expand Down
4 changes: 2 additions & 2 deletions ilc/server/serveStatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ module.exports = function (isProduction) {
return serveStatic('public');
}

require('../systemjs/build');
require('../../systemjs/build');

const webpackDevMiddleware = require('webpack-dev-middleware');
const webpack = require('webpack');
const webpackConfig = require('../build/webpack.dev');
const webpackConfig = require('../../build/webpack.dev');
const compiler = webpack(webpackConfig);

return [webpackDevMiddleware(compiler), serveStatic('public')];
Expand Down
10 changes: 10 additions & 0 deletions ilc/tsconfig.client.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"include": [
"./client/**/*.ts",
"./client/**/*.js",
"./common/**/*.ts",
"./common/**/*.js",
"./system/**/*.js"
]
}
12 changes: 12 additions & 0 deletions ilc/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"outDir": "dist",
"module": "commonjs",
"target": "es6",
"allowJs": true,
"strict": true,
"esModuleInterop": true
},
"exclude": ["node_modules"],
"include": ["**/*.ts", "**/*.js"]
}
9 changes: 9 additions & 0 deletions ilc/tsconfig.server.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"include": [
"./server/**/*.ts",
"./server/**/*.js",
"./common/**/*.ts",
"./common/**/*.js"
]
}

0 comments on commit dbd5d26

Please sign in to comment.