Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions engine.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* @type {import('@wixc3/engine-cli').EngineConfig}
*/
module.exports = {
/** @type {import('@wixc3/engine-cli').EngineConfig} */
export default {
featureDiscoveryRoot: 'dist',
buildPlugins: ({ webConfig, nodeConfig }) => {
nodeConfig.packages = 'external';
Expand Down
1 change: 1 addition & 0 deletions examples/cross-iframe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@fixture/cross-iframe",
"version": "48.0.0",
"private": true,
"type": "module",
"scripts": {
"start": "engine --dev",
"test": "npm run test:it",
Expand Down
5 changes: 3 additions & 2 deletions examples/file-server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "@example/file-server",
"version": "48.0.0",
"private": true,
"type": "module",
"scripts": {
"start": "engine --dev",
"test": "npm run test:it && npm run test:unit",
Expand All @@ -10,6 +12,5 @@
"dependencies": {
"@file-services/node": "^9.4.1"
},
"license": "UNLICENSED",
"private": true
"license": "UNLICENSED"
}
2 changes: 1 addition & 1 deletion examples/file-server/src/test/file-server.it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('File Server Feature', function () {
featureName: 'file-server/example',
configName: 'file-server/run',
runOptions: {
projectPath: path.dirname(__dirname),
projectPath: path.dirname(import.meta.dirname),
},
config: [
fileServerFeature.configure({
Expand Down
6 changes: 3 additions & 3 deletions examples/file-server/src/test/file-server.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ describe('file-server Processing env test', () => {
featureName: 'file-server',
env: server,
runtimeOptions: {
projectPath: __dirname,
projectPath: import.meta.dirname,
},
feature: Feature,
});

const remoteFile = remoteFiles.readFile(path.basename(__filename));
expect(remoteFile).to.eq(fs.readFileSync(__filename, 'utf8'));
const remoteFile = remoteFiles.readFile(path.basename(import.meta.filename));
expect(remoteFile).to.eq(fs.readFileSync(import.meta.filename, 'utf8'));
});
});
5 changes: 3 additions & 2 deletions examples/multi-env/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "@example/multi-env",
"version": "48.0.0",
"private": true,
"type": "module",
"scripts": {
"start": "engine --dev",
"test": "npm run test:it && npm run test:unit",
"test:it": "mocha \"dist/test/**/*.it.js\"",
"test:unit": "mocha \"dist/test/**/*.unit.js\""
},
"license": "UNLICENSED",
"private": true
"license": "UNLICENSED"
}
2 changes: 1 addition & 1 deletion examples/multi-env/src/test/file-server.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('multi-env Processing env test', () => {
featureName: 'multi-env/test-node',
env: processingEnv,
runtimeOptions: {
projectPath: __dirname,
projectPath: import.meta.dirname,
},
feature: Feature,
});
Expand Down
3 changes: 2 additions & 1 deletion examples/node-only/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "@example/node-only",
"version": "48.0.0",
"private": true,
"type": "module",
"main": "index.js",
"license": "MIT",
"private": true,
"scripts": {
"start": "engine --dev"
}
Expand Down
5 changes: 3 additions & 2 deletions examples/playground/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "@example/playground",
"version": "48.0.0",
"private": true,
"type": "module",
"scripts": {
"start": "engine --dev"
},
"license": "UNLICENSED",
"private": true
"license": "UNLICENSED"
}
5 changes: 3 additions & 2 deletions examples/react/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "@examples/react",
"version": "48.0.0",
"private": true,
"type": "module",
"main": "index.js",
"scripts": {
"start": "engine --dev -f react/someplugin",
"test": "npm run test:it",
"test:it": "mocha \"dist/test/**/*.it.js\""
},
"license": "UNLICENSED",
"private": true
"license": "UNLICENSED"
}
2 changes: 1 addition & 1 deletion examples/react/src/test/react.it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('React Feature', function () {
const { getLoadedFeature } = withFeature({
featureName: 'react/someplugin',
runOptions: {
projectPath: join(__dirname, '..'),
projectPath: join(import.meta.dirname, '..'),
},
});

Expand Down
2 changes: 1 addition & 1 deletion examples/react/src/test/react.persist.it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('react/someplugin persistent checks', function () {
const { getLoadedFeature } = withFeature({
featureName: 'react/someplugin',
runOptions: {
projectPath: path.join(__dirname, '..'),
projectPath: path.join(import.meta.dirname, '..'),
},
persist: true,
});
Expand Down
5 changes: 3 additions & 2 deletions examples/reloaded-iframe/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "@example/reloaded-iframe",
"version": "48.0.0",
"private": true,
"type": "module",
"scripts": {
"start": "engine --dev",
"test": "npm run test:it",
"test:it": "mocha \"dist/test/**/*.it.js\""
},
"private": true
}
}
2 changes: 1 addition & 1 deletion guides/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
export default {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
20 changes: 5 additions & 15 deletions guides/docs/getting-started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ mkdir hello-engine && cd hello-engine && git init && npm init -y
Let's make a node application, in typescript.

```bash
npm install --saveDev typescript stylable
npm install typescript -D

```

In your blank typescript repo:

1. install engine-core package `npm i @wixc3/engine-core`
2. install dev-dependencies `npm i -D typescript webpack html-webpack-plugin react stylable`
3. install engineer as a dev dependency `npm i -D @wixc3/engineer`
4. if this is a typescript project, in the root of the project create an `engine.config.js` file, and inside we should
2. install engine-cli as a dev dependency `npm i -D @wixc3/engine-cli`
3. if this is a typescript project, in the root of the project create an `engine.config.js` file, and inside we should
add one of the following:

```ts
module.exports = {
/** @type {import('@wixc3/engine-cli').EngineConfig} */
export default {
// the folder where the transpiled js files will be located
featureDiscoveryRoot: 'dist',
};
Expand Down Expand Up @@ -82,16 +82,6 @@ export default new Feature({
});
```

create `webpack.config.js` file and add:

```js
const { StylableWebpackPlugin } = require('@stylable/webpack-plugin');

module.exports = {
plugins: [new StylableWebpackPlugin()],
};
```

We create the feature file, in which we declare what is the feature's API and its Id.
We also create a new environment - `my-env`.

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"name": "engine",
"private": true,
"type": "module",
"workspaces": [
"examples/*",
"packages/*",
Expand Down Expand Up @@ -62,6 +64,5 @@
"typescript": "~5.7.2",
"typescript-eslint": "^8.18.0"
},
"license": "MIT",
"private": true
"license": "MIT"
}
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@wixc3/engine-core",
"version": "48.0.0",
"type": "module",
"main": "dist/index.js",
"exports": {
".": "./dist/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/com/communication-errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Message } from './message-types';
import { redactArguments } from './helpers';
import type { Message } from './message-types.js';
import { redactArguments } from './helpers.js';

export class EngineCommunicationError extends Error {
constructor(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/com/communication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {
EnvironmentDisconnectedError,
UnConfiguredMethodError,
UnknownCallbackIdError,
} from './communication-errors';
} from './communication-errors.js';

export interface ConfigEnvironmentRecord extends EnvironmentRecord {
registerMessageHandler?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/com/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// we cannot mix types of "dom" and "webworker". tsc fails building.
declare let WorkerGlobalScope: new () => Worker;

import { Message } from './message-types';
import { Message } from './message-types.js';

export function isWorkerContext(target: unknown): target is Worker {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/helpers/web.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IRunOptions } from '../types';
import type { IRunOptions } from '../types.js';

export function injectScript(win: Window, rootComId: string, scriptUrl: string) {
return new Promise<Window>((res, rej) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/polyfills/report-error-polyfill.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { reportError } from '../com';
import { reportError } from '../com/index.js';

/**
* This polyfill is not essential for the engine itself. But applications built
Expand Down
1 change: 1 addition & 0 deletions packages/engine-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@wixc3/engine-cli",
"version": "48.0.0",
"type": "module",
"bin": {
"engine": "./bin/engine.mjs"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/engine-cli/src/analyze-command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { nodeFs as fs } from '@file-services/node';
import type { EngineConfig } from './types';
import { analyzeFeatures } from './find-features/analyze-features';
import type { EngineConfig } from './types.js';
import { analyzeFeatures } from './find-features/analyze-features.js';

export async function analyzeCommand({
engineConfig,
Expand All @@ -14,7 +14,7 @@ export async function analyzeCommand({
const { extensions, buildConditions, featureDiscoveryRoot } = engineConfig;

const { features } = await analyzeFeatures(fs, rootDir, featureDiscoveryRoot, feature, extensions, buildConditions);
const htmlTemplate = fs.readFileSync(fs.join(__dirname, 'dashboard/feature-walker.html'), 'utf8');
const htmlTemplate = fs.readFileSync(fs.join(import.meta.dirname, 'dashboard/feature-walker.html'), 'utf8');
const replaceString = 'globalThis.EMBEDDED_DATA = new Map();';
if (!htmlTemplate.includes(replaceString)) {
throw new Error(`Cannot find "${replaceString}" in the feature-walker.html template`);
Expand Down
8 changes: 4 additions & 4 deletions packages/engine-cli/src/create-entrypoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
IConfigDefinition,
} from '@wixc3/engine-runtime-node';
import { SetMultiMap } from '@wixc3/patterns';
import type { IFeatureDefinition } from './types';
import type { getResolvedEnvironments } from './environments';
import { createNodeEntrypoint, createNodeEnvironmentManagerEntrypoint } from './entrypoint/create-node-entrypoint';
import { createMainEntrypoint } from './entrypoint/create-web-entrypoint';
import type { IFeatureDefinition } from './types.js';
import type { getResolvedEnvironments } from './environments.js';
import { createNodeEntrypoint, createNodeEnvironmentManagerEntrypoint } from './entrypoint/create-node-entrypoint.js';
import { createMainEntrypoint } from './entrypoint/create-web-entrypoint.js';

export interface CreateEntryPointOptions {
dev: boolean;
Expand Down
18 changes: 7 additions & 11 deletions packages/engine-cli/src/create-environments-build-configuration.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { BuildOptions, Plugin } from 'esbuild';
import { topLevelConfigPlugin } from './top-level-config-plugin-esbuild';
import { join } from 'node:path';
import { htmlPlugin } from './esbuild-html-plugin';
import { dynamicEntryPlugin } from './esbuild-dynamic-entry-plugin';
import { EntryPoints, EntryPointsPaths } from './create-entrypoints';
import type { OverrideConfigHook } from './types';
import { BuildOptions, Plugin } from 'esbuild';
import { topLevelConfigPlugin } from './top-level-config-plugin-esbuild.js';
import { htmlPlugin } from './esbuild-html-plugin.js';
import { dynamicEntryPlugin } from './esbuild-dynamic-entry-plugin.js';
import { EntryPoints, EntryPointsPaths } from './create-entrypoints.js';
import type { OverrideConfigHook } from './types.js';

export interface CreateBuildConfigOptions {
dev: boolean;
Expand Down Expand Up @@ -46,11 +46,7 @@ export function createBuildConfiguration(options: CreateBuildConfigOptions) {
const commonConfig = {
target: 'es2020',
bundle: true,
/*
using iife here because esm makes debugging very slow to pickup variables in scope.
if one want to change this to esm, make sure that some bundle splitting is happening.
*/
format: 'iife',
format: 'esm',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barak007 let's discuss this. I saw no other way to get native esm working downstream.

publicPath,
metafile: true,
sourcemap: true,
Expand Down
8 changes: 4 additions & 4 deletions packages/engine-cli/src/engine-app-manager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { loadEngineConfig, runEngine } from './engine-build';
import { resolveRuntimeOptions } from './resolve-runtime-options';
import { runLocalNodeManager } from './run-local-mode-manager';
import { loadEngineConfig, runEngine } from './engine-build.js';
import { resolveRuntimeOptions } from './resolve-runtime-options.js';
import { runLocalNodeManager } from './run-local-mode-manager.js';
import isCI from 'is-ci';
import type { IExecutableApplication, IFeatureTarget } from './types.js';
import { join } from 'path';
Expand All @@ -9,7 +9,7 @@ import {
type FeatureEnvironmentMapping,
readMetadataFiles,
} from '@wixc3/engine-runtime-node';
import { checkWatchSignal } from './watch-signal';
import { checkWatchSignal } from './watch-signal.js';

export const OUTPUT_PATH = process.env.ENGINE_OUTPUT_PATH || join(process.cwd(), 'dist-engine');

Expand Down
Loading