Skip to content

Commit

Permalink
Update files to ESM format
Browse files Browse the repository at this point in the history
  • Loading branch information
niksy committed Mar 23, 2024
1 parent 6435dd3 commit 08de314
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 65 deletions.
26 changes: 12 additions & 14 deletions generators/app/templates/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
'use strict';

const path = require('path');<% if ( codeCoverage ) { %>
const fs = require('fs');<% } %><% if ( bundlingTool === 'webpack' ) { %>
const stdLibBrowser = require('node-stdlib-browser');<% } %><% if ( bundlingTool === 'rollup' ) { %>
const { default: resolve } = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const nodeBuiltins = require('rollup-plugin-node-builtins');
const globals = require('rollup-plugin-node-globals');<% if ( transpile ) { %>
const { default: babel } = require('@rollup/plugin-babel');<% } %><% if ( codeCoverage ) { %>
const istanbul = require('rollup-plugin-istanbul');<% } %>
const rollupConfig = require('./rollup.config');<% } %><% if ( browserTestType === 'headless' ) { %>
const puppeteer = require('puppeteer');
import path from 'node:path';<% if ( codeCoverage ) { %>
import fs from 'node:fs';<% } %><% if ( bundlingTool === 'webpack' ) { %>
import stdLibBrowser from 'node-stdlib-browser';<% } %><% if ( bundlingTool === 'rollup' ) { %>
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import nodeBuiltins from 'rollup-plugin-node-builtins';
import globals from 'rollup-plugin-node-globals';<% if ( transpile ) { %>
import babel from '@rollup/plugin-babel';<% } %><% if ( codeCoverage ) { %>
import istanbul from 'rollup-plugin-istanbul';<% } %>
import rollupConfig from './rollup.config.js';<% } %><% if ( browserTestType === 'headless' ) { %>
import puppeteer from 'puppeteer';

process.env.CHROME_BIN = puppeteer.executablePath();<% } %>

Expand Down Expand Up @@ -52,7 +50,7 @@ if ( local ) {
};
}

module.exports = function ( baseConfig ) {
export default function ( baseConfig ) {

baseConfig.set(Object.assign({
basePath: '',
Expand Down
24 changes: 11 additions & 13 deletions generators/app/templates/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
'use strict';<% if ( transpile ) { %>
<% if ( transpile ) { %>import babel from '@rollup/plugin-babel';<% } %><% if ( vanillaJsWidget ) { %>
import path from 'node:path';
import svelte from 'rollup-plugin-svelte';
import babelCore from '@babel/core';<% } %><% if ( typescript ) { %>
import execa from 'execa';
import cpy from 'cpy';<% if ( !transpile && typescriptMode === 'full' ) { %>
import typescript from '@rollup/plugin-typescript';<% } %><% if ( transpile && typescriptMode === 'full' ) { %>
import resolve from '@rollup/plugin-node-resolve';<% } %><% } %>
import path from 'node:path';
import { promises as fs } from 'node:fs';

const { default: babel } = require('@rollup/plugin-babel');<% } %><% if ( vanillaJsWidget ) { %>
const path = require('path');
const svelte = require('rollup-plugin-svelte');
const babelCore = require('@babel/core');<% } %><% if ( typescript ) { %>
const execa = require('execa');
const cpy = require('cpy');<% if ( !transpile && typescriptMode === 'full' ) { %>
const typescript = require('@rollup/plugin-typescript');<% } %><% if ( transpile && typescriptMode === 'full' ) { %>
const { default: resolve } = require('@rollup/plugin-node-resolve');<% } %><% } %>
const path = require('path');
const { promises: fs } = require('fs');

module.exports = {
export default {
input: '<% if ( complexTranspile ) { %>src/<% } %>index.<%= extension || 'js' %>',
output: [<% if ( bundleCjs ) { %>
{
Expand Down
1 change: 0 additions & 1 deletion generators/app/templates/test/manual/index.js
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
'use strict';
26 changes: 12 additions & 14 deletions generators/app/templates/test/manual/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
'use strict';

const path = require('path');
const del = require('del');
const globby = require('globby');
const minimist = require('minimist');
const staticSite = require('rollup-plugin-static-site');
const postcss = require('rollup-plugin-postcss');
const serve = require('rollup-plugin-serve');<% if ( transpile ) { %>
const { default: babel } = require('@rollup/plugin-babel');<% } %><% if ( !transpile && typescript && typescriptMode === 'full' ) { %>
const typescript = require('@rollup/plugin-typescript');<% } %>
const atImport = require('postcss-import');
const postcssPresetEnv = require('postcss-preset-env');
import path from 'node:path';
import del from 'del';
import globby from 'globby';
import minimist from 'minimist';
import staticSite from 'rollup-plugin-static-site';
import postcss from 'rollup-plugin-postcss';
import serve from 'rollup-plugin-serve';<% if ( transpile ) { %>
import babel from '@rollup/plugin-babel';<% } %><% if ( !transpile && typescript && typescriptMode === 'full' ) { %>
import typescript from '@rollup/plugin-typescript';<% } %>
import atImport from 'postcss-import';
import postcssPresetEnv from 'postcss-preset-env';

const args = minimist(process.argv.slice(2), {
'default': {
Expand Down Expand Up @@ -87,4 +85,4 @@ const config = async () => {

};

module.exports = config();
export default config();
23 changes: 11 additions & 12 deletions generators/app/templates/test/manual/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
'use strict';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import del from 'del';
import globby from 'globby';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import atImport from 'postcss-import';
import postcssPresetEnv from 'postcss-preset-env';

const path = require('path');
const del = require('del');
const globby = require('globby');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const atImport = require('postcss-import');
const postcssPresetEnv = require('postcss-preset-env');

module.exports = async () => {
export default async () => {

const port = 0;

Expand All @@ -32,12 +31,12 @@ module.exports = async () => {
entry: entries,
output: {
filename: '[name].js',
path: path.resolve(__dirname, '../../test-dist'),
path: fileURLToPath(new URL('../../test-dist', import.meta.url)),
},
mode: 'none',
devtool: 'inline-source-map',
devServer: {
contentBase: path.join(__dirname, '../../test-dist'),
contentBase: fileURLToPath(new URL('../../test-dist', import.meta.url)),
port: port,
host: '0.0.0.0',
disableHostCheck: true,
Expand Down
20 changes: 9 additions & 11 deletions generators/app/templates/wdio.conf.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
'use strict';
import path from 'node:path';
import http from 'node:http';
import ws from 'local-web-server';
import shutdown from 'http-shutdown';

const path = require('path');
const http = require('http');
const ws = require('local-web-server');
const shutdown = require('http-shutdown');

let server, config;
let server, _config;

// Pull requests not handled as in case of Karma
const local = <% if ( cloudBrowsers ) { %>typeof process.env.CI === 'undefined' || process.env.CI === 'false'<% } else { %>true<% } %>;
const port = 0;

if ( local ) {
config = {
_config = {
baseUrl: `http://host.docker.internal:${port}`,
services: [[
'docker', {
Expand All @@ -32,7 +30,7 @@ if ( local ) {
}]
};
}<% if ( cloudBrowsers ) { %> else {
config = {
_config = {
baseUrl: `http://localhost:${port}`,
user: process.env.BROWSER_STACK_USERNAME,
key: process.env.BROWSER_STACK_ACCESS_KEY,
Expand All @@ -50,7 +48,7 @@ if ( local ) {
};
}<% } %>

module.exports.config = Object.assign({
export const config = Object.assign({
specs: [
'./test/integration/**/*.<%= extension || 'js' %>'
],
Expand Down Expand Up @@ -113,4 +111,4 @@ module.exports.config = Object.assign({
});

}
}, config);
}, _config);

0 comments on commit 08de314

Please sign in to comment.