From e148090b967119c911c5da2fc7cb2cfdf4c3de39 Mon Sep 17 00:00:00 2001 From: Ghislain Beaulac Date: Tue, 17 Mar 2020 16:57:01 -0400 Subject: [PATCH] fix(build): vscode chrome debugger + webpack prod build should both work --- packages/common/.vscode/launch.json | 73 --------------------- packages/common/package.json | 9 ++- packages/common/tsconfig.build.json | 6 +- packages/common/tsconfig.json | 6 +- packages/vanilla-bundle/package.json | 10 +-- packages/vanilla-bundle/tsconfig.build.json | 6 +- packages/vanilla-bundle/tsconfig.json | 4 +- packages/vanilla-bundle/webpack.config.js | 9 +-- 8 files changed, 29 insertions(+), 94 deletions(-) delete mode 100644 packages/common/.vscode/launch.json diff --git a/packages/common/.vscode/launch.json b/packages/common/.vscode/launch.json deleted file mode 100644 index 895efc97b..000000000 --- a/packages/common/.vscode/launch.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - // Use IntelliSense to find out which attributes exist for node debugging - // Use hover for the description of the existing attributes - // For further information visit https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Chrome Debugger", - "type": "chrome", - "request": "launch", - "breakOnLoad": false, - "url": "http://localhost:9000", - "webRoot": "${workspaceRoot}/src", - "userDataDir": "${workspaceRoot}/.chrome", - "sourceMapPathOverrides": { - "webpack:///./src/*": "${webRoot}/*" - } - }, - { - "type": "node", - "request": "launch", - "name": "Jest All Tests", - "program": "${workspaceFolder}/node_modules/.bin/jest", - "args": [ - "--runInBand", - "--config", - "${workspaceFolder}/test/jest.config.js" - ], - "console": "internalConsole", - "internalConsoleOptions": "neverOpen", - "windows": { - "program": "${workspaceFolder}/node_modules/jest/bin/jest", - } - }, - { - "type": "node", - "request": "launch", - "name": "Jest Current Spec File", - "program": "${workspaceFolder}/node_modules/.bin/jest", - "args": [ - "--runInBand", - "${fileBasename}", - "--config", - "${workspaceFolder}/test/jest.config.js" - ], - "console": "internalConsole", - "internalConsoleOptions": "neverOpen", - "disableOptimisticBPs": true, - "windows": { - "program": "${workspaceFolder}/node_modules/jest/bin/jest", - } - }, - { - "type": "node", - "request": "launch", - "name": "Jest Selected Test Name", - "program": "${workspaceFolder}/node_modules/.bin/jest", - "args": [ - "--runInBand", - "${fileBasename}", - "--config", - "${workspaceFolder}/test/jest.config.js", - "-t=${selectedText}$", - "--watch" - ], - "console": "internalConsole", - "internalConsoleOptions": "neverOpen", - "windows": { - "program": "${workspaceFolder}/node_modules/jest/bin/jest", - } - } - ] -} diff --git a/packages/common/package.json b/packages/common/package.json index bfa0ee53b..e96284027 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -2,13 +2,18 @@ "name": "@slickgrid-universal/common", "version": "0.0.2", "description": "SlickGrid-Universal Common Code", - "main": "src/index.ts", - "typings": "dist/es2020/index.d.ts", + "browser": "src/index.ts", + "main": "dist/es2015/index.js", + "typings": "dist/es2015/index.d.ts", "author": "Ghislain B.", "license": "MIT", "publishConfig": { "access": "public" }, + "files": [ + "src", + "dist" + ], "scripts": { "build": "cross-env tsc --build", "build:watch": "cross-env tsc --incremental --watch", diff --git a/packages/common/tsconfig.build.json b/packages/common/tsconfig.build.json index bc1499457..407988bc5 100644 --- a/packages/common/tsconfig.build.json +++ b/packages/common/tsconfig.build.json @@ -1,10 +1,10 @@ { "compilerOptions": { - "module": "es2015", + "module": "es2020", "moduleResolution": "node", - "target": "es5", + "target": "es2015", "lib": [ - "es2017", + "es2020", "dom" ], "typeRoots": [ diff --git a/packages/common/tsconfig.json b/packages/common/tsconfig.json index 2dda1d5b2..59625f7ab 100644 --- a/packages/common/tsconfig.json +++ b/packages/common/tsconfig.json @@ -3,8 +3,8 @@ "compileOnSave": false, "compilerOptions": { "rootDir": "src", - "declarationDir": "dist/es2020", - "outDir": "dist/es2020", + "declarationDir": "dist/es2015", + "outDir": "dist/es2015", "target": "es2017", "module": "es2015", "sourceMap": true, @@ -37,4 +37,4 @@ "src/**/*.ts", "src/typings/**/*.ts" ] -} \ No newline at end of file +} diff --git a/packages/vanilla-bundle/package.json b/packages/vanilla-bundle/package.json index b00c0ad91..eacd9b27a 100644 --- a/packages/vanilla-bundle/package.json +++ b/packages/vanilla-bundle/package.json @@ -2,11 +2,13 @@ "name": "@slickgrid-universal/vanilla-bundle", "version": "0.0.2", "description": "Vanilla Slick Grid Bundle - Framework agnostic the output is to be used in vanilla JS/TS - Written in TypeScript and we also use WebPack to bundle everything into 1 JS file.", + "browser": "src/index.ts", "main": "src/index.ts", - "typings": "dist/es2020/index.d.ts", - "directories": { - "src": "src" - }, + "typings": "dist/es2015/index.d.ts", + "files": [ + "src", + "dist" + ], "scripts": { "test": "echo testing slickgrid-universal slickgrid-vanilla-bundle code", "dev": "webpack --env.development", diff --git a/packages/vanilla-bundle/tsconfig.build.json b/packages/vanilla-bundle/tsconfig.build.json index bc1499457..407988bc5 100644 --- a/packages/vanilla-bundle/tsconfig.build.json +++ b/packages/vanilla-bundle/tsconfig.build.json @@ -1,10 +1,10 @@ { "compilerOptions": { - "module": "es2015", + "module": "es2020", "moduleResolution": "node", - "target": "es5", + "target": "es2015", "lib": [ - "es2017", + "es2020", "dom" ], "typeRoots": [ diff --git a/packages/vanilla-bundle/tsconfig.json b/packages/vanilla-bundle/tsconfig.json index ac4f199cc..59625f7ab 100644 --- a/packages/vanilla-bundle/tsconfig.json +++ b/packages/vanilla-bundle/tsconfig.json @@ -3,8 +3,8 @@ "compileOnSave": false, "compilerOptions": { "rootDir": "src", - "declarationDir": "dist/es2020", - "outDir": "dist/es2020", + "declarationDir": "dist/es2015", + "outDir": "dist/es2015", "target": "es2017", "module": "es2015", "sourceMap": true, diff --git a/packages/vanilla-bundle/webpack.config.js b/packages/vanilla-bundle/webpack.config.js index 370cb00f9..d316b0922 100644 --- a/packages/vanilla-bundle/webpack.config.js +++ b/packages/vanilla-bundle/webpack.config.js @@ -9,7 +9,7 @@ const outDir = path.resolve(__dirname, 'dist'); const srcDir = path.resolve(__dirname, 'src'); const nodeModulesDir = path.resolve(__dirname, 'node_modules'); -module.exports = ({ production } = {}, { port, host } = {}) => ({ +module.exports = ({ production } = {}) => ({ mode: production ? 'production' : 'development', entry: { app: [`${srcDir}/index.ts`], @@ -17,11 +17,12 @@ module.exports = ({ production } = {}, { port, host } = {}) => ({ stats: { warnings: false }, + devtool: production ? 'nosources-source-map' : 'cheap-module-eval-source-map', output: { path: `${outDir}/bundle`, publicPath: baseUrl, - filename: production ? 'slickgrid-vanilla-bundle.js' : 'slickgrid-vanilla-bundle.js', - sourceMapFilename: production ? 'slickgrid-vanilla-bundle.map' : 'slickgrid-vanilla-bundle.map', + filename: 'slickgrid-vanilla-bundle.js', + sourceMapFilename: 'slickgrid-vanilla-bundle.map', libraryTarget: 'umd', library: 'MyLib', umdNamedDefine: true @@ -29,6 +30,7 @@ module.exports = ({ production } = {}, { port, host } = {}) => ({ resolve: { extensions: ['.ts', '.js'], modules: [srcDir, 'node_modules'], + mainFields: production ? ['module', 'main'] : ['browser', 'module'], alias: { moment$: 'moment/moment.js' } @@ -38,5 +40,4 @@ module.exports = ({ production } = {}, { port, host } = {}) => ({ { test: /\.ts?$/, use: 'ts-loader', exclude: nodeModulesDir, }, ], }, - devtool: production ? 'nosources-source-map' : 'cheap-module-eval-source-map', });