diff --git a/README.md b/README.md index 612deb0..8e526b0 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,6 @@ This will cause `npx` to download the `makes` tool, along with the `aurelia` sca ## Development -This scaffolding skeleton is in the early stage, not quite ready for adding features. We want to keep feature set manageable as Aurelia 2 is constantly evolving. - There are some tests for this skeleton, setup in package.json. (totally not required by makes) ## Unit tests diff --git a/app-min/test__if_not_no-unit-tests/my-app.spec.ext b/app-min/test__if_not_no-unit-tests/my-app.spec.ext index bc8ccfc..8bb0597 100644 --- a/app-min/test__if_not_no-unit-tests/my-app.spec.ext +++ b/app-min/test__if_not_no-unit-tests/my-app.spec.ext @@ -1,38 +1,27 @@ -// @if mocha -import { expect } from 'chai'; -// @endif // @if vitest -import { describe, it, expect } from 'vitest'; -// @endif -// @if shadow-dom -import { CustomElement } from 'aurelia'; +import { describe, it } from 'vitest'; // @endif -import { render } from './helper'; import { MyApp } from '../src/my-app'; +import { createFixture } from '@aurelia/testing'; +// @if jest +import { bootstrapTestEnvironment } from './setup'; + +beforeAll(bootstrapTestEnvironment); +// @endif describe('my-app', () => { it('should render message', async () => { - const node = (await render('', MyApp)).firstElementChild; - // @if shadow-dom - // In Shadow DOM open mode, shadowRoot is also accessible through DOM API - // node.shadowRoot - // But only Aurelia API can access shadowRoot in both open and closed mode. - const shadowRoot = CustomElement.for(node).shadowRoot; - // @if babel - const text = shadowRoot.textContent; - // @endif - // @if typescript - const text = (shadowRoot as Node).textContent; - // @endif - // @endif - // @if !shadow-dom - const text = node.textContent; - // @endif - // @if jasmine || jest || vitest - expect(text.trim()).toBe('Hello World!'); - // @endif - // @if mocha - expect(text.trim()).to.equal('Hello World!'); - // @endif + const { assertText, startPromise, stop } = createFixture( + '', + {}, + [MyApp], + ); + + try { + await startPromise; + assertText('Hello World!', { compact: true }); + } finally { + await stop(true); + } }); }); diff --git a/common/.eslintrc.json b/common/.eslintrc.json index ddd5a29..363f6ce 100644 --- a/common/.eslintrc.json +++ b/common/.eslintrc.json @@ -22,15 +22,9 @@ }, "env": { - "es6": true, + "es2024": true, "browser": true, "node": true, - // @if jasmine - "jasmine": true, - // @endif - // @if mocha - "mocha": true, - // @endif // @if jest "jest": true, // @endif diff --git a/common/.htmlhintrc__skip-if-exists b/common/.htmlhintrc__skip-if-exists deleted file mode 100644 index 7c147d8..0000000 --- a/common/.htmlhintrc__skip-if-exists +++ /dev/null @@ -1,12 +0,0 @@ -{ - "tagname-lowercase": true, - "attr-lowercase": false, - "attr-value-double-quotes": true, - "attr-no-duplication": true, - "doctype-first": false, - "tag-pair": true, - "spec-char-escape": true, - "id-unique": true, - "src-not-empty": true, - "title-require": true -} diff --git a/common/.stylelintrc.json__skip-if-exists b/common/.stylelintrc.json__skip-if-exists index 78d0a73..b1f26cd 100644 --- a/common/.stylelintrc.json__skip-if-exists +++ b/common/.stylelintrc.json__skip-if-exists @@ -6,9 +6,6 @@ // @if sass "stylelint-config-standard-scss", // @endif - // @if less - "stylelint-config-standard-less", - // @endif // @if css-module "stylelint-config-css-modules" // @endif diff --git a/common/README.md__skip-if-exists b/common/README.md__skip-if-exists index 7e4ef2e..f6b50be 100644 --- a/common/README.md__skip-if-exists +++ b/common/README.md__skip-if-exists @@ -93,18 +93,4 @@ Run unit tests in watch mode. npm run test:watch -// @if jasmine || mocha -Unit tests run in browser through [browser-do](https://github.com/3cp/browser-do). Please check scripts in `package.json` for more details. - -By default, browser-do shuts down browser after tests. To keep browser window open for inspection, pass additional argument `-k` or `--keep-open`. - - npm run build:test && browser-do -k /* @if jasmine */--jasmine/* @endif *//* @if mocha */--mocha/* @endif */ --browser chrome < dist/entry.bundle.js - -// @if webpack -Unit tests in watch mode is executed through stand webpack watch mode and the help of [webpack-shell-plugin-next](https://github.com/s00d/webpack-shell-plugin-next). -// @endif -// @if dumber -Unit tests in watch mode is executed through standard `gulp.watch` with the help of [gulp-run](https://github.com/MrBoolean/gulp-run). -// @endif -// @endif // @endif diff --git a/common/package.json b/common/package.json index 246a4d4..9d901a0 100644 --- a/common/package.json +++ b/common/package.json @@ -28,23 +28,16 @@ "devDependencies": { "eslint": "^8.57.0", "@aurelia/testing": /* @if latest */"latest"/* @endif *//* @if dev */"dev"/* @endif */, - "htmlhint": "^1.1.4", "stylelint": "^16.3.1", // @if css "stylelint-config-standard": "^36.0.0", // @endif - // @if less - "stylelint-config-standard-less": "^3.0.1", - // @endif // @if sass "stylelint-config-standard-scss": "^13.1.0", // @endif // @if css-module "stylelint-config-css-modules": "^4.4.0", // @endif - // @if jasmine || mocha - "browser-do": "^4.1.0", - // @endif }, "scripts": { "lint:js": "eslint src/* @if !no-unit-tests */ test/* @endif *//* @if playwright */ e2e/* @endif *//* @if typescript */ --ext .js,.ts/* @endif */", @@ -54,17 +47,7 @@ // @if sass "lint:css": "stylelint \"src/**/*.scss\"", // @endif - // @if less - "lint:css": "stylelint \"src/**/*.less\"", - // @endif - "lint:html": "htmlhint -c .htmlhintrc src", - "lint": "npm run lint:js && npm run lint:html && npm run lint:css", - // @if jest + "lint": "npm run lint:js && npm run lint:css", "pretest": "npm run lint", - // @endif - // @if jasmine || mocha - "test": "npm run test:headless", - "pretest": "npm run lint && npm run build:test", - // @endif } } diff --git a/common/src/main.ext__if_app b/common/src/main.ext__if_app index 958a924..daa5946 100644 --- a/common/src/main.ext__if_app +++ b/common/src/main.ext__if_app @@ -13,7 +13,7 @@ import { MyApp } from './my-app'; // They are for sharedStyles in shadowDOM. // However, css files imported in other js/ts files are processed by style-loader. // @endif -// import shared from './shared./* @if css */css/* @endif *//* @if less */less/* @endif *//* @if sass */scss/* @endif */'; +// import shared from './shared./* @if css */css/* @endif *//* @if sass */scss/* @endif */'; // @endif Aurelia diff --git a/common/src/resource.d.ts__if_typescript b/common/src/resource.d.ts__if_typescript index d3ef093..69ccc3e 100644 --- a/common/src/resource.d.ts__if_typescript +++ b/common/src/resource.d.ts__if_typescript @@ -15,12 +15,6 @@ declare module '*.module.css' { const value: Record; export default value; } -// @if less -declare module '*.module.less' { - const value: Record; - export default value; -} -// @endif // @if sass declare module '*.module.scss' { const value: Record; @@ -30,9 +24,6 @@ declare module '*.module.scss' { // @endif // @if !css-module declare module '*.css'; -// @if less -declare module '*.less'; -// @endif // @if sass declare module '*.scss'; // @endif diff --git a/common/test__if_not_no-unit-tests/helper.ext b/common/test__if_not_no-unit-tests/helper.ext deleted file mode 100644 index abcaa84..0000000 --- a/common/test__if_not_no-unit-tests/helper.ext +++ /dev/null @@ -1,11 +0,0 @@ -import Aurelia, { CustomElement } from 'aurelia'; -export async function render(template/* @if typescript */: string/* @endif */, ...deps/* @if typescript */: readonly unknown[]/* @endif */)/* @if typescript */: Promise/* @endif */ { - const wrapper = CustomElement.define({name: 'wrapper', template}); - const div = document.createElement('div'); - const au = Aurelia.register(deps).app({ - host: div, - component: wrapper - }); - await au.start(); - return div; -} diff --git a/common/test__if_not_no-unit-tests/setup.ext b/common/test__if_not_no-unit-tests/setup.ext new file mode 100644 index 0000000..d4f84d2 --- /dev/null +++ b/common/test__if_not_no-unit-tests/setup.ext @@ -0,0 +1,16 @@ +import { BrowserPlatform } from '@aurelia/platform-browser'; +import { setPlatform } from '@aurelia/testing'; + +// Sets up the Aurelia environment for testing +// @if vitest +const platform = new BrowserPlatform(window); +setPlatform(platform); +BrowserPlatform.set(globalThis, platform); +// @endif +// @if jest +export function bootstrapTestEnvironment() { + const platform = new BrowserPlatform(window); + setPlatform(platform); + BrowserPlatform.set(globalThis, platform); +} +// @endif diff --git a/common/test__if_not_no-unit-tests/setup.ext__if_ava b/common/test__if_not_no-unit-tests/setup.ext__if_ava deleted file mode 100644 index 270f8be..0000000 --- a/common/test__if_not_no-unit-tests/setup.ext__if_ava +++ /dev/null @@ -1,9 +0,0 @@ -import 'jsdom-global/register'; -// ignore css modules -function skipCSS(module) { - module.exports = ''; -} - -require.extensions['.css'] = skipCSS; -require.extensions['.less'] = skipCSS; -require.extensions['.scss'] = skipCSS; diff --git a/dumber/gulpfile.js b/dumber/gulpfile.js index 3e80400..a026c8e 100644 --- a/dumber/gulpfile.js +++ b/dumber/gulpfile.js @@ -17,9 +17,6 @@ const devServer = require('./dev-server'); // @if css-module const cssModule = require('gulp-dumber-css-module'); // @endif -// @if less -const less = require('gulp-less'); -// @endif // @if sass const sass = require('gulp-dart-sass'); const sassPackageImporter = require('node-sass-package-importer'); @@ -27,12 +24,8 @@ const sassPackageImporter = require('node-sass-package-importer'); const postcss = require('gulp-postcss'); const autoprefixer = require('autoprefixer'); const postcssUrl = require('postcss-url'); -// @if jasmine || mocha -const gulpRun = require('gulp-run'); -// @endif const isProduction = process.env.NODE_ENV === 'production'; -const isTest = process.env.NODE_ENV === 'test'; const dist = 'dist'; // Read more in https://dumber.js.org @@ -58,16 +51,6 @@ const dr = dumber({ // dumber-module-loader is injected automatically by dumber bundler after prepends. // prepend: [], - // @if jasmine || mocha - // append after amd loader and all module definitions in entry bundle. - append: [ - // Kick off all test files. - // Note dumber-module-loader requirejs call accepts regex which loads all matched module ids! - // Note all module ids are relative to dumber option "src" (default to 'src') folder. - isTest && "requirejs([/^\\.\\.\\/test\\/.+\\.spec$/]);" - ], - // @endif - // Explicit dependencies, can use either "deps" (short name) or "dependencies" (full name). // deps: [], @@ -88,8 +71,7 @@ const dr = dumber({ // for npm package file "node_modules/foo/bar.js", the package name is "foo" // for npm package file "node_modules/@scoped/foo/bar.js", the package name is "@scoped/foo" - // Here we skip code splitting in test mode. - codeSplit: isTest ? undefined : function (moduleId, packageName) { + codeSplit: function (moduleId, packageName) { // Here for any local src, put into app-bundle if (!packageName) return 'app-bundle'; // The codeSplit func does not need to return a valid bundle name. @@ -108,7 +90,7 @@ const dr = dumber({ // "other-bundle.js": "other-bundle.js" // } // If you turned on hash, you need this callback to update index.html - onManifest: isTest ? undefined : function (filenameMap) { + onManifest: function (filenameMap) { // Update index.html entry.bundle.js with entry.bundle.hash...js console.log('Update index.html with ' + filenameMap['entry.bundle.js']); const indexHtml = fs.readFileSync('_index.html').toString() @@ -123,7 +105,7 @@ function buildJs(src) { const ts = typescript.createProject('tsconfig.json', { noEmitOnError: true }); // @endif return gulp.src(src, { sourcemaps: !isProduction }) - .pipe(gulpif(!isProduction && !isTest, plumber())) + .pipe(gulpif(!isProduction, plumber())) .pipe(au2()) // @if babel .pipe(babel()); @@ -135,7 +117,7 @@ function buildJs(src) { function buildHtml(src) { return gulp.src(src) - .pipe(gulpif(!isProduction && !isTest, plumber())) + .pipe(gulpif(!isProduction, plumber())) // @if shadow-dom // The other possible Shadow DOM mode is "closed". // If you turn on "closed" mode, there will be difficulty to perform e2e @@ -150,16 +132,12 @@ function buildHtml(src) { function buildCss(src) { return gulp.src(src, { sourcemaps: !isProduction }) - // @if less - .pipe(gulpif(!isProduction && !isTest, plumber())) - .pipe(gulpif(f => f.extname === '.less', less())) - // @endif // @if sass .pipe(gulpif( f => f.extname === '.scss', // sassPackageImporter handles @import "~bootstrap" // https://github.com/maoberlehner/node-sass-magic-importer/tree/master/packages/node-sass-package-importer - isProduction || isTest ? + isProduction ? sass.sync({ quietDeps: true, importer: sassPackageImporter() }) : sass.sync({ quietDeps: true, importer: sassPackageImporter() }).on('error', sass.logError) )) @@ -180,34 +158,21 @@ function buildCss(src) { function build() { // Merge all js/css/html file streams to feed dumber. - // dumber knows nothing about .ts/.less/.scss/.md files, + // dumber knows nothing about .ts/.scss/.md files, // gulp-* plugins transpiled them into js/css/html before // sending to dumber. return merge2( gulp.src('src/**/*.json'), // @if babel - // @if !jasmine && !mocha buildJs('src/**/*.js'), // @endif - // @if jasmine || mocha - buildJs(isTest ? '{src,test}/**/*.js' : 'src/**/*.js'), - // @endif - // @endif // @if typescript - // @if !jasmine && !mocha buildJs('src/**/*.ts'), // @endif - // @if jasmine || mocha - buildJs(isTest ? '{src,test}/**/*.ts' : 'src/**/*.ts'), - // @endif - // @endif buildHtml('src/**/*.html'), // @if css buildCss('src/**/*.css') // @endif - // @if less - buildCss('src/**/*.{less,css}') - // @endif // @if sass buildCss('src/**/*.{scss,css}') // @endif @@ -220,12 +185,7 @@ function build() { // https://github.com/terser-js/terser#terser-fast-minify-mode // It's a good balance on size and speed to turn off compress. .pipe(gulpif(isProduction, terser({ compress: false }))) - // @if !jasmine && !mocha .pipe(gulp.dest(dist, { sourcemaps: isProduction ? false : '.' })); - // @endif - // @if jasmine || mocha - .pipe(gulp.dest(dist, { sourcemaps: isProduction ? false : (isTest ? true : '.') })); - // @endif } function clean() { @@ -261,18 +221,6 @@ function watch() { const run = gulp.series(clean, serve, watch); -// @if jasmine || mocha -// Watch all files for rebuild and test. -function watchTest() { - gulp.watch('{src,test}/**/*', gulp.series(build, test)); -} - -function test() { - return gulpRun('npm run test:headless').exec(); -} - -exports['watch-test'] = watchTest; -// @endif exports.build = build; exports.clean = clean; exports['clear-cache'] = clearCache; diff --git a/dumber/package.json b/dumber/package.json index a4e6271..b9918f9 100644 --- a/dumber/package.json +++ b/dumber/package.json @@ -26,9 +26,6 @@ // @if css-module "gulp-dumber-css-module": "^0.1.1", // @endif - // @if less - "gulp-less": "^5.0.0", - // @endif // @if sass "gulp-dart-sass": "^1.1.0", "node-sass-package-importer": "^5.3.3", @@ -37,18 +34,11 @@ "postcss": "^8.4.38", "autoprefixer": "^10.4.19", "postcss-url": "^10.1.3", - // @if jasmine || mocha - "gulp-run": "^1.7.1", - // @endif }, "scripts": { "start": "gulp", "build": "gulp clean && cross-env NODE_ENV=production gulp build", "clear-cache": "gulp clear-cache", - // @if jasmine || mocha - "build:test": "gulp clean && cross-env NODE_ENV=test gulp build", - "test:watch": "gulp clean && cross-env NODE_ENV=test gulp watch-test" - // @endif }, // npm v8 feature to bypass outdated gulp deps "overrides": { diff --git a/e2e-test.js b/e2e-test.js index 084ce37..09c8554 100644 --- a/e2e-test.js +++ b/e2e-test.js @@ -160,7 +160,7 @@ skeletons.forEach((features, i) => { if (features.includes('playwright')) { console.log('-- npx playwright test --project chromium'); - await run('npx playwright install --with-deps', appFolder); + await run('npx playwright install chromium --with-deps', appFolder); await run('npx playwright test --project chromium', appFolder); } diff --git a/jasmine/package.json b/jasmine/package.json deleted file mode 100644 index dbd091f..0000000 --- a/jasmine/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "devDependencies": { - "jasmine-core": "^5.1.2", - // @if typescript - "@types/jasmine": "^5.1.4", - // @endif - }, - "scripts": { - // @if !parcel - "test:headless": "browser-do --jasmine < dist/entry.bundle.js", - "test:chrome": "browser-do --jasmine --browser chrome < dist/entry.bundle.js" - // @endif - // @if parcel - "test:headless": "browser-do --jasmine < dist/all-spec.js", - "test:chrome": "browser-do --jasmine --browser chrome < dist/all-spec.js" - // @endif - } -} diff --git a/jest/package.json b/jest/package.json index 26bb496..9431f7f 100644 --- a/jest/package.json +++ b/jest/package.json @@ -20,7 +20,7 @@ ], "testEnvironment": "jsdom", "transform": { - "\\.(css|less|sass|scss|styl|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "jest-transform-stub", + "\\.(css|sass|scss|styl|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "jest-transform-stub", // @if babel // @if shadow-dom "\\.(js|html)$": [ "@aurelia/babel-jest", { defaultShadowOptions: { mode: 'open' } } ] diff --git a/mocha/package.json b/mocha/package.json deleted file mode 100644 index 2818c5d..0000000 --- a/mocha/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "devDependencies": { - "mocha": "^10.4.0", - "chai": "^5.1.0", - // @if typescript - "@types/mocha": "^10.0.6", - // @endif - // @if parcel - "buffer": "^6.0.3", - // @endif - }, - "scripts": { - // @if !parcel - "test:headless": "browser-do --mocha < dist/entry.bundle.js", - "test:chrome": "browser-do --mocha --browser chrome < dist/entry.bundle.js" - // @endif - // @if parcel - "test:headless": "browser-do --mocha < dist/all-spec.js", - "test:chrome": "browser-do --mocha --browser chrome < dist/all-spec.js" - // @endif - } -} diff --git a/parcel/.parcelrc b/parcel/.parcelrc index 96b0f90..3dc77ad 100644 --- a/parcel/.parcelrc +++ b/parcel/.parcelrc @@ -8,8 +8,5 @@ "*.ts": ["@aurelia/parcel-transformer", "@parcel/transformer-typescript-tsc"], // @endif "*.html": ["@aurelia/parcel-transformer", "..."] - }, - // @if jasmine || mocha - "resolvers": ["@parcel/resolver-glob", "..."], - // @endif + } } diff --git a/parcel/package.json b/parcel/package.json index 5486b68..969c27f 100644 --- a/parcel/package.json +++ b/parcel/package.json @@ -5,32 +5,15 @@ // @if typescript "@parcel/transformer-typescript-tsc": "^2.12.0", // @endif - // @if less - "@parcel/transformer-less": "^2.12.0", - // @endif // @if sass "@parcel/transformer-sass": "^2.12.0", // @endif - // @if jasmine || mocha - "@parcel/resolver-glob": "^2.12.0", - // @endif - // @if mocha - "process": "^0.11.10", - // @endif "@parcel/transformer-inline-string": "^2.12.0", "parcel": "^2.12.0" }, "scripts": { "start": "parcel -p 9000", "build": "parcel build --no-scope-hoist --no-source-maps", - // @if jasmine || mocha - // @if babel - "build:test": "parcel build --no-scope-hoist test/all-spec.js", - // @endif - // @if typescript - "build:test": "parcel build --no-scope-hoist test/all-spec.ts", - // @endif - // @endif }, "targets": { "default": { diff --git a/playwright/playwright.config.mjs b/playwright/playwright.config.mjs index 26d7224..eaa4d3d 100644 --- a/playwright/playwright.config.mjs +++ b/playwright/playwright.config.mjs @@ -50,19 +50,19 @@ export default defineConfig({ }, }, - { - name: 'firefox', - use: { - ...devices['Desktop Firefox'], - }, - }, + // { + // name: 'firefox', + // use: { + // ...devices['Desktop Firefox'], + // }, + // }, - { - name: 'webkit', - use: { - ...devices['Desktop Safari'], - }, - }, + // { + // name: 'webkit', + // use: { + // ...devices['Desktop Safari'], + // }, + // }, /* Test against mobile viewports. */ // { diff --git a/plugin-min/dev-app/main.ext b/plugin-min/dev-app/main.ext index 35dfefd..4295421 100644 --- a/plugin-min/dev-app/main.ext +++ b/plugin-min/dev-app/main.ext @@ -10,7 +10,7 @@ import { MyApp } from './my-app'; // They are for sharedStyles in shadowDOM. // However, css files imported in other js/ts files are processed by style-loader. // @endif -// import shared from './shared./* @if css */css/* @endif *//* @if less */less/* @endif *//* @if sass */scss/* @endif */'; +// import shared from './shared./* @if css */css/* @endif *//* @if sass */scss/* @endif */'; // @endif import * as Plugin from "../src/index"; diff --git a/plugin-min/test__if_not_no-unit-tests/hello-world.spec.ext b/plugin-min/test__if_not_no-unit-tests/hello-world.spec.ext index 4740cec..ebf63a2 100644 --- a/plugin-min/test__if_not_no-unit-tests/hello-world.spec.ext +++ b/plugin-min/test__if_not_no-unit-tests/hello-world.spec.ext @@ -1,38 +1,27 @@ -// @if mocha -import { expect } from 'chai'; -// @endif // @if vitest -import { describe, it, expect } from 'vitest'; -// @endif -// @if shadow-dom -import { CustomElement } from 'aurelia'; +import { describe, it } from 'vitest'; // @endif -import { render } from './helper'; import { HelloWorld } from '../src/hello-world'; +import { createFixture } from '@aurelia/testing'; +// @if jest +import { bootstrapTestEnvironment } from './setup'; -describe('hello-world', () => { +beforeAll(bootstrapTestEnvironment); +// @endif + +describe('my-app', () => { it('should render message', async () => { - const node = (await render('', HelloWorld)).firstElementChild; - // @if shadow-dom - // In Shadow DOM open mode, shadowRoot is also accessible through DOM API - // node.shadowRoot - // But only Aurelia API can access shadowRoot in both open and closed mode. - const shadowRoot = CustomElement.for(node).shadowRoot; - // @if babel - const text = shadowRoot.textContent; - // @endif - // @if typescript - const text = (shadowRoot as Node).textContent; - // @endif - // @endif - // @if !shadow-dom - const text = node.textContent; - // @endif - // @if jasmine || jest || vitest - expect(text.trim()).toBe('Hello World! foo'); - // @endif - // @if mocha - expect(text.trim()).to.equal('Hello World! foo'); - // @endif + const { assertText, startPromise, stop } = createFixture( + '', + { message: "foo" }, + [HelloWorld], + ); + + try { + await startPromise; + assertText('Hello World! foo', { compact: true }); + } finally { + await stop(true); + } }); }); diff --git a/questions.js b/questions.js index a470859..4f20324 100644 --- a/questions.js +++ b/questions.js @@ -35,14 +35,13 @@ module.exports = [ {title: 'No'}, {if: 'app', value: 'shadow-dom', title: 'Use Shadow DOM', hint: 'Shadow DOM in open mode, shadowRoot is accessible through DOM API.'}, {if: 'plugin', value: 'shadow-dom', title: 'Use Shadow DOM (Recommended for plugin project)', hint: 'Shadow DOM in open mode, shadowRoot is accessible through DOM API.'}, - {value: 'css-module', title: 'Use CSS Module', hint: 'CSS Module is an alternative way to locally scope CSS class names. We use .module.css/less/scss file name convention.'}, + {value: 'css-module', title: 'Use CSS Module', hint: 'CSS Module is an alternative way to locally scope CSS class names. We use .module.css/scss file name convention.'}, ] }, { message: 'What CSS preprocessor to use?', choices: [ {value: 'css', title: 'Plain CSS'}, - {value: 'less', title: 'Less (.less)'}, {value: 'sass', title: 'Sass (.scss)'} ] }, @@ -51,8 +50,6 @@ module.exports = [ choices: [ {value: 'no-unit-tests', title: 'None', hint: 'No unit testing'}, {if: '!vite', value: 'jest', title: 'Jest', hint: 'Runs in Node.js, simulates browser by default, with a focus on simplicity.'}, - {if: '!vite', value: 'jasmine', title: 'Jasmine', hint: 'Runs in browser, a behavior-driven testing framework.'}, - {if: '!vite', value: 'mocha', title: 'Mocha + Chai', hint: 'Runs in browser, a feature-rich JavaScript test framework for node and browsers.'}, {if: 'vite', value: 'vitest', title:'Vitest', hint: 'A Vite-native testing framework.'} ] }, diff --git a/transforms.js b/transforms.js index 2eff04f..66a7784 100644 --- a/transforms.js +++ b/transforms.js @@ -9,7 +9,7 @@ exports.append = function(properties, features) { // change .ext to .ts or .js file file.extname = features.includes('typescript') ? '.ts' : '.js'; } else if (features.includes('css-module')) { - if (['.css', '.less', '.scss'].includes(file.extname)) { + if (['.css', '.scss'].includes(file.extname)) { file.extname = `.module${file.extname}`; } } diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json index f7fc605..295c112 100644 --- a/typescript/tsconfig.json +++ b/typescript/tsconfig.json @@ -15,9 +15,6 @@ "sourceMap": true }, "include": [ - // @if jest || jasmine || mocha - "test", - // @endif "src" ], "files": [ diff --git a/vite/package.json b/vite/package.json index bb8eca4..911cbfc 100644 --- a/vite/package.json +++ b/vite/package.json @@ -14,9 +14,6 @@ "vitest": "^1.6.0", "jsdom": "^24.1.0", // @endif - // @if less - "less": "^4.2.0", - // @endif // @if sass "sass": "^1.77.3", // @endif diff --git a/vite/vitest.config.ext__if_vitest b/vite/vitest.config.ext__if_vitest index 1261649..4639a1d 100644 --- a/vite/vitest.config.ext__if_vitest +++ b/vite/vitest.config.ext__if_vitest @@ -12,6 +12,7 @@ export default mergeConfig( exclude: [...configDefaults.exclude, "e2e/*"], // @endif root: fileURLToPath(new URL("./", import.meta.url)), + setupFiles: ['./test/setup./* @if babel */js/* @endif *//* @if typescript */ts/* @endif */'] }, }), ); \ No newline at end of file diff --git a/webpack/package.json b/webpack/package.json index bd76e89..bb38b56 100644 --- a/webpack/package.json +++ b/webpack/package.json @@ -15,10 +15,6 @@ // @if typescript "ts-loader": "^9.5.1", // @endif - // @if less - "less-loader": "^12.2.0", - "less": "^4.2.0", - // @endif // @if sass "sass-loader": "^14.1.1", "sass": "^1.72.0", @@ -26,9 +22,6 @@ "postcss-loader": "^8.1.1", "postcss": "^8.4.38", "autoprefixer": "^10.4.19", - // @if jasmine || mocha - "webpack-shell-plugin-next": "^2.3.1", - // @endif // @if plugin "webpack-node-externals": "^3.0.0", // @endif @@ -37,9 +30,5 @@ "start": "webpack serve", "build": "webpack --env production", "analyze": "webpack --env production --analyze", - // @if jasmine || mocha - "build:test": "webpack --env test", - "test:watch": "webpack --env test --watch --runTest" - // @endif } } diff --git a/webpack/webpack.config.js b/webpack/webpack.config.js index eac1478..970520a 100644 --- a/webpack/webpack.config.js +++ b/webpack/webpack.config.js @@ -6,9 +6,6 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer'); const Dotenv = require('dotenv-webpack'); const TerserPlugin = require('terser-webpack-plugin'); -// @if jasmine || mocha -const WebpackShellPluginNext = require('webpack-shell-plugin-next') -// @endif // @if plugin const nodeExternals = require('webpack-node-externals'); // @endif @@ -33,11 +30,8 @@ const postcssLoader = { } }; -module.exports = function(env, { /* @if jasmine || mocha*/runTest, /* @endif */analyze }) { +module.exports = function(env, { analyze }) { const production = env.production || process.env.NODE_ENV === 'production'; - // @if jasmine || mocha - const test = env.test || process.env.NODE_ENV === 'test'; - // @endif return { // @if app target: 'web', @@ -60,41 +54,25 @@ module.exports = function(env, { /* @if jasmine || mocha*/runTest, /* @endif */a }), ], }, - // @if jasmine || mocha - entry: { - entry: test ? - './test/all-spec./* @if babel */js/* @endif *//* @if typescript */ts/* @endif */' : - // @if app - './src/main./* @if babel */js/* @endif *//* @if typescript */ts/* @endif */' - // @endif - // @if plugin - // Build only plugin in production mode, - // build dev-app in non-production mode - (production ? './src/index./* @if babel */js/* @endif *//* @if typescript */ts/* @endif */' : './dev-app/main./* @if babel */js/* @endif *//* @if typescript */ts/* @endif */') - // @endif - }, - // @endif - // @if !jasmine && !mocha entry: { // @if app - entry: './src/main./* @if babel */js/* @endif *//* @if typescript */ts/* @endif */' + entry: './src/main./* @if babel */js/* @endif *//* @if typescript */ts/* @endif */', // @endif // @if plugin // Build only plugin in production mode, // build dev-app in non-production mode - entry: production? './src/index./* @if babel */js/* @endif *//* @if typescript */ts/* @endif */' : './dev-app/main./* @if babel */js/* @endif *//* @if typescript */ts/* @endif */' + entry: production? './src/index./* @if babel */js/* @endif *//* @if typescript */ts/* @endif */' : './dev-app/main./* @if babel */js/* @endif *//* @if typescript */ts/* @endif */', // @endif }, - // @endif output: { clean: true, path: path.resolve(__dirname, 'dist'), // @if app - filename: production ? '[name].[contenthash].bundle.js' : '[name].bundle.js' + filename: production ? '[name].[contenthash].bundle.js' : '[name].bundle.js', // @endif // @if plugin filename: production ? 'index.js' : '[name].bundle.js', - library: production ? { type: 'commonjs' } : undefined + library: production ? { type: 'commonjs' } : undefined, // @endif }, resolve: { @@ -118,9 +96,6 @@ module.exports = function(env, { /* @if jasmine || mocha*/runTest, /* @endif */a { test: /\.(woff|woff2|ttf|eot|svg|otf)(\?v=[0-9]\.[0-9]\.[0-9])?$/i, type: 'asset' }, // @if !shadow-dom { test: /\.css$/i, use: [ 'style-loader', 'css-loader', postcssLoader ] }, - // @if less - { test: /\.less$/i, use: [ 'style-loader', 'css-loader', postcssLoader, 'less-loader' ] }, - // @endif // @if sass { test: /\.scss$/i, use: [ 'style-loader', 'css-loader', postcssLoader, sassLoader ] }, // @endif @@ -133,15 +108,6 @@ module.exports = function(env, { /* @if jasmine || mocha*/runTest, /* @endif */a issuer: /[/\\]src[/\\]main\.(js|ts)$/, use: [ 'css-loader', postcssLoader ] }, - // @if less - { - test: /\.less$/i, - // For style loaded in src/main.js, it's not loaded by style-loader. - // It's for shared styles for shadow-dom only. - issuer: /[/\\]src[/\\]main\.(js|ts)$/, - use: [ 'css-loader', postcssLoader, 'less-loader' ] - }, - // @endif // @if sass { test: /\.scss$/i, @@ -158,15 +124,6 @@ module.exports = function(env, { /* @if jasmine || mocha*/runTest, /* @endif */a issuer: /(? p) } }