diff --git a/.gitignore b/.gitignore index 01a2cd1ad..1f638cb91 100644 --- a/.gitignore +++ b/.gitignore @@ -6,9 +6,9 @@ /out-tsc # dependencies -node_modules -package-lock.json -yarn-lock.json +**/node_modules +**/package-lock.json +**/yarn.lock # IDEs and editors /.idea diff --git a/nx.json b/nx.json index e3adc53f7..20d0fcd77 100644 --- a/nx.json +++ b/nx.json @@ -42,6 +42,9 @@ }, "webpack": { "tags": [] + }, + "webpack5": { + "tags": [] } } } diff --git a/packages/webpack5/.gitignore b/packages/webpack5/.gitignore new file mode 100644 index 000000000..4e768b56d --- /dev/null +++ b/packages/webpack5/.gitignore @@ -0,0 +1 @@ +# \ No newline at end of file diff --git a/packages/webpack5/package.json b/packages/webpack5/package.json new file mode 100644 index 000000000..3d4b1fbc6 --- /dev/null +++ b/packages/webpack5/package.json @@ -0,0 +1,13 @@ +{ + "name": "@nativescript/webpack", + "version": "4.0.0-dev", + "private": true, + "main": "index.js", + "license": "Apache-2.0", + "scripts": { + "build": "echo todo" + }, + "devDependencies": { + "webpack": "^5.4.0" + } +} diff --git a/packages/webpack5/src/configuration/angular.ts b/packages/webpack5/src/configuration/angular.ts new file mode 100644 index 000000000..cf84269ef --- /dev/null +++ b/packages/webpack5/src/configuration/angular.ts @@ -0,0 +1,8 @@ +import base from './base'; + +// todo: add base configuration for angular +export default function (env) { + const config = base(env); + + return {}; +} diff --git a/packages/webpack5/src/configuration/base.ts b/packages/webpack5/src/configuration/base.ts new file mode 100644 index 000000000..b275614c5 --- /dev/null +++ b/packages/webpack5/src/configuration/base.ts @@ -0,0 +1,6 @@ +import { Configuration } from 'webpack'; + +// todo: add base configuration that's shared across all flavors +export default function (env): Configuration { + return {}; +} diff --git a/packages/webpack5/src/configuration/index.ts b/packages/webpack5/src/configuration/index.ts new file mode 100644 index 000000000..43da5349f --- /dev/null +++ b/packages/webpack5/src/configuration/index.ts @@ -0,0 +1,7 @@ +export { default as angularConfig } from './angular'; +export { default as baseConfig } from './base'; +export { default as javascriptConfig } from './javascript'; +export { default as reactConfig } from './react'; +export { default as svelteConfig } from './svelte'; +export { default as typescriptConfig } from './typescript'; +export { default as vueConfig } from './vue'; diff --git a/packages/webpack5/src/configuration/javascript.ts b/packages/webpack5/src/configuration/javascript.ts new file mode 100644 index 000000000..480da5522 --- /dev/null +++ b/packages/webpack5/src/configuration/javascript.ts @@ -0,0 +1,8 @@ +import base from './base'; + +// todo: add base configuration for core +export default function (env) { + const config = base(env); + + return {}; +} diff --git a/packages/webpack5/src/configuration/react.ts b/packages/webpack5/src/configuration/react.ts new file mode 100644 index 000000000..fe5e9eaf6 --- /dev/null +++ b/packages/webpack5/src/configuration/react.ts @@ -0,0 +1,8 @@ +import base from './base'; + +// todo: add base configuration for react +export default function (env) { + const config = base(env); + + return {}; +} diff --git a/packages/webpack5/src/configuration/svelte.ts b/packages/webpack5/src/configuration/svelte.ts new file mode 100644 index 000000000..2c277a244 --- /dev/null +++ b/packages/webpack5/src/configuration/svelte.ts @@ -0,0 +1,8 @@ +import base from './base'; + +// todo: add base configuration for svelte +export default function (env) { + const config = base(env); + + return {}; +} diff --git a/packages/webpack5/src/configuration/typescript.ts b/packages/webpack5/src/configuration/typescript.ts new file mode 100644 index 000000000..480da5522 --- /dev/null +++ b/packages/webpack5/src/configuration/typescript.ts @@ -0,0 +1,8 @@ +import base from './base'; + +// todo: add base configuration for core +export default function (env) { + const config = base(env); + + return {}; +} diff --git a/packages/webpack5/src/configuration/vue.ts b/packages/webpack5/src/configuration/vue.ts new file mode 100644 index 000000000..9f2347901 --- /dev/null +++ b/packages/webpack5/src/configuration/vue.ts @@ -0,0 +1,15 @@ +import base from './base'; + +// todo: add base configuration for vue +export default function (env) { + const config = base(env); + + // todo: we may want to use webpack-chain internally + // to avoid "trying to read property x of undefined" type of issues + config.module.rules.push({ + test: /.vue$/, + use: [], + }); + + return {}; +} diff --git a/packages/webpack5/src/index.ts b/packages/webpack5/src/index.ts new file mode 100644 index 000000000..75a11149d --- /dev/null +++ b/packages/webpack5/src/index.ts @@ -0,0 +1 @@ +export * from './configuration'; diff --git a/packages/webpack5/src/loaders/css2json-loader/index.ts b/packages/webpack5/src/loaders/css2json-loader/index.ts new file mode 100644 index 000000000..8337712ea --- /dev/null +++ b/packages/webpack5/src/loaders/css2json-loader/index.ts @@ -0,0 +1 @@ +// diff --git a/packages/webpack5/src/transformers/AngularHMR/index.ts b/packages/webpack5/src/transformers/AngularHMR/index.ts new file mode 100644 index 000000000..65b3dba38 --- /dev/null +++ b/packages/webpack5/src/transformers/AngularHMR/index.ts @@ -0,0 +1 @@ +// todo diff --git a/packages/webpack5/src/transformers/NativeClass/index.ts b/packages/webpack5/src/transformers/NativeClass/index.ts new file mode 100644 index 000000000..65b3dba38 --- /dev/null +++ b/packages/webpack5/src/transformers/NativeClass/index.ts @@ -0,0 +1 @@ +// todo diff --git a/packages/webpack5/tsconfig.json b/packages/webpack5/tsconfig.json new file mode 100644 index 000000000..ccf9cdcf1 --- /dev/null +++ b/packages/webpack5/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "rootDir": ".", + "baseUrl": ".", + "target": "es2015", + "module": "commonjs", + "declaration": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "lib": [ "es2017" ], + "sourceMap": true, + "skipLibCheck": true, + "skipDefaultLibCheck": true, + "diagnostics": true + }, + "exclude": [ + "node_modules", + ] +} diff --git a/tools/workspace-scripts.js b/tools/workspace-scripts.js index 53fb315a2..2ff7477e7 100644 --- a/tools/workspace-scripts.js +++ b/tools/workspace-scripts.js @@ -115,6 +115,13 @@ module.exports = { test: { script: 'nx run webpack:test', description: '@nativescript/webpack: Unit tests' + }, + }, + // @nativescript/webpack (5) + webpack5: { + build: { + script: 'nx run webpack5:build', + description: '@nativescript/webpack(5): Build for npm' }, }, }, diff --git a/workspace.json b/workspace.json index f31778a13..7c5ed0f36 100644 --- a/workspace.json +++ b/workspace.json @@ -253,6 +253,31 @@ } } } + }, + "webpack5": { + "root": "packages/webpack5", + "sourceRoot": "packages/webpack5", + "projectType": "library", + "schematics": {}, + "architect": { + "lint": { + "builder": "@nrwl/linter:eslint", + "options": { + "lintFilePatterns": [] + } + }, + "build": { + "builder": "@nrwl/workspace:run-commands", + "outputs": ["dist/packages"], + "options": { + "commands": [ + "npm run build" + ], + "cwd": "packages/webpack5", + "parallel": false + } + } + } } }, "cli": {