Skip to content

Commit

Permalink
feat!: use native esm
Browse files Browse the repository at this point in the history
  • Loading branch information
AviVahl committed Aug 27, 2023
1 parent fce7059 commit 77bda75
Show file tree
Hide file tree
Showing 93 changed files with 225 additions and 128 deletions.
2 changes: 1 addition & 1 deletion engine.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @type {import('@wixc3/engine-scripts').EngineConfig}
*/
module.exports = {
export default {
featureDiscoveryRoot: 'dist',
};
1 change: 1 addition & 0 deletions examples/cross-iframe/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@fixture/cross-iframe",
"version": "40.0.7",
"type": "module",
"private": true,
"scripts": {
"start": "engineer start",
Expand Down
1 change: 1 addition & 0 deletions examples/electron-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "electron-app",
"description": "sample engine application running in electron",
"version": "40.0.7",
"type": "module",
"private": true,
"license": "UNLICENSED",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions examples/file-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@example/file-server",
"version": "40.0.7",
"type": "module",
"scripts": {
"start": "engineer start",
"test": "yarn test:it && yarn test:unit",
Expand Down
9 changes: 5 additions & 4 deletions examples/file-server/src/test/file-server.it.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import path from 'node:path';
import { withFeature } from '@wixc3/engine-test-kit';
import { waitFor } from 'promise-assist';
import { expect } from 'chai';
import { fileURLToPath } from 'node:url';
import { waitFor } from 'promise-assist';
import fileServerFeature, { MAIN_MARK, SERVER_MARK } from '../feature/file-server.feature.js';
import { FileServerDriver } from './file-server-driver.js';
import fileServerFeature, { SERVER_MARK, MAIN_MARK } from '../feature/file-server.feature.js';

describe('File Server Feature', function () {
this.timeout(20_000);
const projectPath = fileURLToPath(new URL('..', import.meta.url));

const { getLoadedFeature } = withFeature({
featureName: 'file-server/example',
configName: 'file-server/run',
runOptions: {
projectPath: path.dirname(__dirname),
projectPath,
},
config: [
fileServerFeature.use({
Expand Down
10 changes: 7 additions & 3 deletions examples/file-server/src/test/file-server.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ import path from 'node:path';
import { getRunningFeature } from '@wixc3/engine-test-kit';
import Feature, { server } from '../feature/file-server.feature.js';
import { expect } from 'chai';
import { fileURLToPath } from 'node:url';

describe('file-server Processing env test', () => {
const selfPath = fileURLToPath(import.meta.url);
const projectPath = fileURLToPath(new URL('.', import.meta.url));

it('reads directory', async () => {
const {
runningApi: { remoteFiles },
} = await getRunningFeature({
featureName: 'file-server',
env: server,
runtimeOptions: {
projectPath: __dirname,
projectPath,
},
feature: Feature,
});

const remoteFile = remoteFiles.readFile(path.basename(__filename));
expect(remoteFile).to.eq(fs.readFileSync(__filename, 'utf8'));
const remoteFile = remoteFiles.readFile(path.basename(selfPath));
expect(remoteFile).to.eq(fs.readFileSync(selfPath, 'utf8'));
});
});
1 change: 1 addition & 0 deletions examples/multi-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@example/multi-env",
"version": "40.0.7",
"type": "module",
"scripts": {
"start": "engineer start",
"test": "yarn test:it && yarn test:unit",
Expand Down
7 changes: 5 additions & 2 deletions examples/multi-env/src/test/file-server.unit.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { getRunningFeature } from '@wixc3/engine-test-kit';
import Feature, { processingEnv } from '../feature/multi-env.feature.js';
import { expect } from 'chai';
import { fileURLToPath } from 'node:url';
import Feature, { processingEnv } from '../feature/multi-env.feature.js';

describe('multi-env Processing env test', () => {
it('echos from node env', async () => {
const projectPath = fileURLToPath(new URL('.', import.meta.url));

const { runningApi } = await getRunningFeature({
featureName: 'multi-env/test-node',
env: processingEnv,
runtimeOptions: {
projectPath: __dirname,
projectPath,
},
feature: Feature,
});
Expand Down
2 changes: 1 addition & 1 deletion examples/node-only/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@example/node-only",
"version": "40.0.7",
"main": "index.js",
"type": "module",
"license": "MIT",
"private": true,
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions examples/playground/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@example/playground",
"version": "40.0.7",
"type": "module",
"scripts": {
"build:stylable": "stc --srcDir src --outDir dist --stcss --no-cjs --unsr",
"start": "engineer start"
Expand Down
1 change: 1 addition & 0 deletions examples/preload/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@example/preload",
"version": "40.0.7",
"type": "module",
"scripts": {
"start": "engineer start",
"test": "yarn test:it",
Expand Down
2 changes: 2 additions & 0 deletions examples/preload/src/test/all.it.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { createDisposables } from '@wixc3/create-disposables';
import { expect } from 'chai';
import { createRequire } from 'node:module';
import { dirname } from 'node:path';
import type { Page } from 'playwright-core';
import { startServerNewProcess } from './utils.js';

describe('All Environment', () => {
const require = createRequire(import.meta.url);
const projectPath = dirname(require.resolve('@example/preload/package.json'));
const featureName = 'preload/all';
const disposables = createDisposables();
Expand Down
2 changes: 2 additions & 0 deletions examples/preload/src/test/contextual.it.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { createDisposables } from '@wixc3/create-disposables';
import { expect } from 'chai';
import { createRequire } from 'node:module';
import { dirname } from 'node:path';
import { startServerNewProcess } from './utils.js';

describe('Contextual preload', () => {
const require = createRequire(import.meta.url);
const projectPath = dirname(require.resolve('@example/preload/package.json'));
const disposables = createDisposables();
afterEach(disposables.dispose);
Expand Down
2 changes: 2 additions & 0 deletions examples/preload/src/test/parent.it.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { createDisposables } from '@wixc3/create-disposables';
import { expect } from 'chai';
import { createRequire } from 'node:module';
import { dirname } from 'node:path';
import { startServerNewProcess } from './utils.js';

describe('Parent feature', function () {
const require = createRequire(import.meta.url);
const projectPath = dirname(require.resolve('@example/preload/package.json'));
const featureName = 'preload/parent';
const disposables = createDisposables();
Expand Down
2 changes: 1 addition & 1 deletion examples/react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@examples/react",
"version": "40.0.7",
"main": "index.js",
"type": "module",
"scripts": {
"start": "yarn engineer start -f react/someplugin --singleFeature",
"test": "yarn test:it",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/src/test/react.it.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { withFeature } from '@wixc3/engine-test-kit';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';

describe('React Feature', function () {
this.timeout(20_000);

const { getLoadedFeature } = withFeature({
featureName: 'react/someplugin',
runOptions: {
projectPath: join(__dirname, '..'),
projectPath: fileURLToPath(new URL('..', import.meta.url)),
},
});

Expand Down
4 changes: 2 additions & 2 deletions examples/react/src/test/react.persist.it.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { withFeature } from '@wixc3/engine-test-kit';
import chai, { expect } from 'chai';
import chaiAsPromised from 'chai-as-promised';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { type Page } from 'playwright-core';

chai.use(chaiAsPromised);
Expand All @@ -12,7 +12,7 @@ describe('react/someplugin persistent checks', function () {
const { getLoadedFeature } = withFeature({
featureName: 'react/someplugin',
runOptions: {
projectPath: path.join(__dirname, '..'),
projectPath: fileURLToPath(new URL('..', import.meta.url)),
},
persist: true,
});
Expand Down
1 change: 1 addition & 0 deletions examples/reloaded-iframe/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@example/reloaded-iframe",
"version": "40.0.7",
"type": "module",
"scripts": {
"start": "engineer start",
"test": "yarn test:it",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "engine",
"type": "module",
"workspaces": [
"examples/*",
"packages/*",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@wixc3/engine-core",
"version": "40.0.7",
"main": "dist/index.js",
"type": "module",
"exports": {
".": "./dist/index.js",
"./dist/communication.feature": "./dist/communication.feature.js",
Expand Down
10 changes: 5 additions & 5 deletions packages/core/scripts/bundle.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const webpack = require('webpack');
const path = require('path');
const baseWebpackConfig = require('../../../webpack.config');
import { fileURLToPath } from 'node:url';
import webpack from 'webpack';
import baseWebpackConfig from '../../../webpack.config.js';

const entryPath = require.resolve('../dist/index.js');
const outputPath = path.join(__dirname, '../dist/umd');
const entryPath = fileURLToPath(new URL('../dist/index.js', import.meta.url));
const outputPath = fileURLToPath(new URL('../dist/umd', import.meta.url));

function getConfigForMode(mode) {
return {
Expand Down
7 changes: 4 additions & 3 deletions packages/core/webpack.config.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const HtmlWebpackPlugin = require('html-webpack-plugin');
import HtmlWebpackPlugin from 'html-webpack-plugin';
import { fileURLToPath } from 'node:url';

/** @type {import('webpack').Configuration} */
module.exports = {
export default {
mode: 'development',
context: __dirname,
context: fileURLToPath(new URL('.', import.meta.url)),
entry: {
iframe: './dist/test/iframe.js',
'delayed-iframe': './dist/test/delayed-iframe.js',
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@wixc3/engine-dashboard",
"version": "40.0.7",
"license": "MIT",
"main": "dist/index.js",
"type": "module",
"exports": {
".": "./dist/index.js",
"./dist/graph-utils": "./dist/graph-utils.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-commons/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@wixc3/engine-electron-commons",
"version": "40.0.7",
"main": "dist/index.js",
"type": "module",
"exports": {
".": "./dist/index.js",
"./node-entry": "./dist/node-entry.js",
Expand Down
2 changes: 2 additions & 0 deletions packages/electron-commons/test-kit/setup-running-node-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { BaseHost, Communication, Environment, type TopLevelConfig } from '@wixc
import { initializeNodeEnvironment, type ProcessExitDetails } from '@wixc3/engine-electron-commons';
import { findFeatures } from '@wixc3/engine-scripts';
import type { IOType } from 'node:child_process';
import { createRequire } from 'node:module';
import { deferred } from 'promise-assist';

const require = createRequire(import.meta.url);
const nodeEntryPath = require.resolve('@wixc3/engine-electron-commons/node-entry');

export interface SetupRunningEnvOptions {
Expand Down
8 changes: 5 additions & 3 deletions packages/electron-commons/test/electron-node.unit.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import testFeature, { serverEnv } from '@fixture/disconnecting-env/dist/disconnecting-env.feature.js';
import type { TopLevelConfig } from '@wixc3/engine-core';
import { disposeAfter } from '@wixc3/testing';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import type { IOType } from 'node:child_process';
import { createRequire } from 'node:module';
import path from 'node:path';
import type { TopLevelConfig } from '@wixc3/engine-core';
import testFeature, { serverEnv } from '@fixture/disconnecting-env/dist/disconnecting-env.feature.js';
import { setupRunningNodeEnv } from '../test-kit/setup-running-node-env.js';
import { disposeAfter } from '@wixc3/testing';

const { expect } = chai;
chai.use(chaiAsPromised);

const require = createRequire(import.meta.url);
const featurePath = path.dirname(require.resolve('@fixture/disconnecting-env/package.json'));
const timeout = 3000;

Expand Down
2 changes: 2 additions & 0 deletions packages/electron-commons/test/worker-thread.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import workerThreadFeature, {
} from '@fixture/worker-thread/dist/worker-thread.feature.js';
import { disposeAfter } from '@wixc3/testing';
import { expect } from 'chai';
import { createRequire } from 'node:module';
import { setupRunningNodeEnv } from '../test-kit/setup-running-node-env.js';

const require = createRequire(import.meta.url);
const featurePath = fs.dirname(require.resolve('@fixture/worker-thread/package.json'));

const setupRunningEnv = (featureId: string) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-host/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@wixc3/engine-electron-host",
"version": "40.0.7",
"main": "dist/index.js",
"type": "module",
"exports": {
".": "./dist/index.js",
"./package.json": "./package.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-node/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@wixc3/engine-electron-node",
"version": "40.0.7",
"main": "dist/index.js",
"type": "module",
"exports": {
".": "./dist/index.js",
"./package.json": "./package.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-scripts/bin/engine-electron.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env node

require('../dist/cli');
import '../dist/cli.js';
2 changes: 1 addition & 1 deletion packages/electron-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@wixc3/engine-electron-scripts",
"version": "40.0.7",
"main": "dist/index.js",
"type": "module",
"exports": {
".": "./dist/index.js",
"./dist/commands": "./dist/commands/index.js",
Expand Down
Loading

0 comments on commit 77bda75

Please sign in to comment.