Skip to content

Commit

Permalink
Add file extensions to file imports
Browse files Browse the repository at this point in the history
  • Loading branch information
koddsson committed Nov 8, 2023
1 parent f1b9509 commit 5792e9c
Show file tree
Hide file tree
Showing 252 changed files with 614 additions and 598 deletions.
14 changes: 7 additions & 7 deletions integration/test-runner/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { BrowserLauncher, TestRunnerCoreConfig } from '@web/test-runner-core';
import { runBasicTest } from './tests/basic/runBasicTest';
import { runConfigGroupsTest } from './tests/config-groups/runConfigGroupsTest';
import { runParallelTest } from './tests/parallel/runParallelTest';
import { runTestFailureTest } from './tests/test-failure/runTestFailureTest';
import { runLocationChangeTest } from './tests/location-change/runLocationChangeTest';
import { runFocusTest } from './tests/focus/runFocusTest';
import { runManyTests } from './tests/many/runManyTests';
import { runBasicTest } from './tests/basic/runBasicTest.js';
import { runConfigGroupsTest } from './tests/config-groups/runConfigGroupsTest.js';
import { runParallelTest } from './tests/parallel/runParallelTest.js';
import { runTestFailureTest } from './tests/test-failure/runTestFailureTest.js';
import { runLocationChangeTest } from './tests/location-change/runLocationChangeTest.js';
import { runFocusTest } from './tests/focus/runFocusTest.js';
import { runManyTests } from './tests/many/runManyTests.js';

export interface Tests {
basic: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/browser-logs/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// this file is autogenerated with the generate-mjs-dts-entrypoints script
export * from './dist/index';
export * from './dist/index.js';
2 changes: 1 addition & 1 deletion packages/browser-logs/src/deserialize.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ParseStackTraceOptions, parseStackTrace } from './parseStackTrace';
import { ParseStackTraceOptions, parseStackTrace } from './parseStackTrace.js';

const KEY_WTR_TYPE = '__WTR_TYPE__';
const KEY_CONSTRUCTOR_NAME = '__WTR_CONSTRUCTOR_NAME__';
Expand Down
11 changes: 8 additions & 3 deletions packages/browser-logs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export { deserialize } from './deserialize';
export { browserScript } from './browserScript';
export { parseStackTrace, StackLocation, MapStackLocation } from './parseStackTrace';
export { deserialize } from './deserialize.js';
export { browserScript } from './browserScript.js';
export {
MapBrowserUrl,
parseStackTrace,
StackLocation,
MapStackLocation,
} from './parseStackTrace.js';
2 changes: 1 addition & 1 deletion packages/browser-logs/test/serialize-deserialize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import puppeteer, { Browser, Page } from 'puppeteer';
import fs from 'fs';
import path from 'path';

import { deserialize } from '../src/deserialize';
import { deserialize } from '../src/deserialize.js';

const serializeScript = fs.readFileSync(require.resolve('../dist/serialize.js'), 'utf-8');
const defaultOptions = { browserRootDir: __dirname, cwd: __dirname };
Expand Down
2 changes: 1 addition & 1 deletion packages/config-loader/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './dist/index';
export * from './dist/index.js';
2 changes: 1 addition & 1 deletion packages/dev-server-core/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// this file is autogenerated with the generate-mjs-dts-entrypoints script
export * from './dist/index';
export * from './dist/index.js';
8 changes: 4 additions & 4 deletions packages/dev-server-core/src/dom5/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
export * from './modification';
export * from './predicates';
export * from './util';
export * from './walking';
export * from './modification.js';
export * from './predicates.js';
export * from './util.js';
export * from './walking.js';
4 changes: 2 additions & 2 deletions packages/dev-server-core/src/dom5/iteration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* http://polymer.github.io/PATENTS.txt
*/

import { isElement, Predicate, predicates as p } from './predicates';
import { defaultChildNodes, GetChildNodes } from './util';
import { isElement, Predicate, predicates as p } from './predicates.js';
import { defaultChildNodes, GetChildNodes } from './util.js';

/**
* Applies `mapfn` to `node` and the tree below `node`, yielding a flattened
Expand Down
4 changes: 2 additions & 2 deletions packages/dev-server-core/src/dom5/modification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
*/
import cloneObject from 'clone';

import { isDocumentFragment, predicates as p } from './predicates';
import { queryAll } from './walking';
import { isDocumentFragment, predicates as p } from './predicates.js';
import { queryAll } from './walking.js';

function newTextNode(value: string): any {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-server-core/src/dom5/predicates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* http://polymer.github.io/PATENTS.txt
*/

import { getAttribute, getAttributeIndex, getTextContent } from './util';
import { getAttribute, getAttributeIndex, getTextContent } from './util.js';

/**
* Match the text inside an element, textnode, or comment
Expand Down
12 changes: 9 additions & 3 deletions packages/dev-server-core/src/dom5/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@
* http://polymer.github.io/PATENTS.txt
*/

import { constructors } from './modification';
import { isCommentNode, isDocument, isDocumentFragment, isElement, isTextNode } from './predicates';
import { nodeWalkAll } from './walking';
import { constructors } from './modification.js';
import {
isCommentNode,
isDocument,
isDocumentFragment,
isElement,
isTextNode,
} from './predicates.js';
import { nodeWalkAll } from './walking.js';

/**
* Return the text value of a node or element
Expand Down
6 changes: 3 additions & 3 deletions packages/dev-server-core/src/dom5/walking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
* http://polymer.github.io/PATENTS.txt
*/

import * as iteration from './iteration';
import { isElement, Predicate, predicates as p } from './predicates';
import { defaultChildNodes, GetChildNodes } from './util';
import * as iteration from './iteration.js';
import { isElement, Predicate, predicates as p } from './predicates.js';
import { defaultChildNodes, GetChildNodes } from './util.js';

/**
* Applies `mapfn` to `node` and the tree below `node`, returning a flattened
Expand Down
16 changes: 8 additions & 8 deletions packages/dev-server-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ export { Server } from 'net';
import WebSocket from 'ws';
export { WebSocket };

export { DevServer } from './server/DevServer';
export { Plugin, ServerStartParams, ResolveOptions } from './plugins/Plugin';
export { DevServerCoreConfig, MimeTypeMappings } from './server/DevServerCoreConfig';
export { WebSocketsManager, WebSocketData } from './web-sockets/WebSocketsManager';
export { DevServer } from './server/DevServer.js';
export { Plugin, ServerStartParams, ResolveOptions } from './plugins/Plugin.js';
export { DevServerCoreConfig, MimeTypeMappings } from './server/DevServerCoreConfig.js';
export { WebSocketsManager, WebSocketData } from './web-sockets/WebSocketsManager.js';
export {
getRequestBrowserPath,
getRequestFilePath,
getResponseBody,
getHtmlPath,
isInlineScriptRequest,
} from './utils';
export { Logger, ErrorWithLocation } from './logger/Logger';
export { PluginSyntaxError } from './logger/PluginSyntaxError';
export { PluginError } from './logger/PluginError';
} from './utils.js';
export { Logger, ErrorWithLocation } from './logger/Logger.js';
export { PluginSyntaxError } from './logger/PluginSyntaxError.js';
export { PluginError } from './logger/PluginError.js';
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import LRUCache from 'lru-cache';
import { FSWatcher } from 'chokidar';
import fs from 'fs';
import { promisify } from 'util';
import { RequestCancelledError } from '../utils';
import { RequestCancelledError } from '../utils.js';

const fsStat = promisify(fs.stat);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Middleware } from 'koa';
import path from 'path';
import { toBrowserPath } from '../utils';
import { Logger } from '../logger/Logger';
import { toBrowserPath } from '../utils.js';
import { Logger } from '../logger/Logger.js';

/**
* Serves index.html when a non-file request within the scope of the app index is made.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { FSWatcher } from 'chokidar';
import { Middleware } from 'koa';

import { DevServerCoreConfig } from '../server/DevServerCoreConfig';
import { PluginTransformCache } from './PluginTransformCache';
import { getRequestFilePath, getResponseBody, RequestCancelledError } from '../utils';
import { Logger } from '../logger/Logger';
import type { PluginSyntaxError } from '../logger/PluginSyntaxError';
import { DevServerCoreConfig } from '../server/DevServerCoreConfig.js';
import { PluginTransformCache } from './PluginTransformCache.js';
import { getRequestFilePath, getResponseBody, RequestCancelledError } from '../utils.js';
import { Logger } from '../logger/Logger.js';
import type { PluginSyntaxError } from '../logger/PluginSyntaxError.js';

/**
* Sets up a middleware which allows plugins to transform files before they are served to the browser.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Middleware } from 'koa';
import send from 'koa-send';
import koaStatic, { Options as KoaStaticOptions } from 'koa-static';
import { isOutsideRootDir, resolvePathOutsideRootDir } from '../utils';
import { isOutsideRootDir, resolvePathOutsideRootDir } from '../utils.js';

/**
* Creates multiple middleware used for serving files.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Middleware } from 'koa';
import { FSWatcher } from 'chokidar';
import fs from 'fs';

import { getRequestFilePath } from '../utils';
import { getRequestFilePath } from '../utils.js';

/**
* Sets up a middleware which tracks served files and sends a reload message to any
Expand Down
4 changes: 2 additions & 2 deletions packages/dev-server-core/src/plugins/mimeTypesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import picoMatch from 'picomatch';
import { isAbsolute, posix, sep } from 'path';

import { MimeTypeMappings } from '../server/DevServerCoreConfig';
import { Plugin } from './Plugin';
import { getRequestFilePath } from '../utils';
import { Plugin } from './Plugin.js';
import { getRequestFilePath } from '../utils.js';

function createMatcher(rootDir: string, pattern: string) {
const resolvedPattern =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { Context } from 'koa';
// @ts-ignore
import { parse, ParsedImport } from 'es-module-lexer';

import { queryAll, predicates, getTextContent, setTextContent } from '../dom5';
import { queryAll, predicates, getTextContent, setTextContent } from '../dom5/index.js';
import { parse as parseHtml, serialize as serializeHtml } from 'parse5';
import { Plugin } from './Plugin';
import { PluginSyntaxError } from '../logger/PluginSyntaxError';
import { toFilePath } from '../utils';
import { Logger } from '../logger/Logger';
import { parseDynamicImport } from './parseDynamicImport';
import { Plugin } from './Plugin.js';
import { PluginSyntaxError } from '../logger/PluginSyntaxError.js';
import { toFilePath } from '../utils.js';
import { Logger } from '../logger/Logger.js';
import { parseDynamicImport } from './parseDynamicImport.js';

export type ResolveImport = (
source: string,
Expand Down
8 changes: 4 additions & 4 deletions packages/dev-server-core/src/server/DevServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { ListenOptions, Server, Socket } from 'net';
import chokidar from 'chokidar';
import { promisify } from 'util';

import { DevServerCoreConfig } from './DevServerCoreConfig';
import { createServer } from './createServer';
import { Logger } from '../logger/Logger';
import { WebSocketsManager } from '../web-sockets/WebSocketsManager';
import { DevServerCoreConfig } from './DevServerCoreConfig.js';
import { createServer } from './createServer.js';
import { Logger } from '../logger/Logger.js';
import { WebSocketsManager } from '../web-sockets/WebSocketsManager.js';

export class DevServer {
public koaApp: Koa;
Expand Down
10 changes: 5 additions & 5 deletions packages/dev-server-core/src/server/addPlugins.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DevServerCoreConfig } from './DevServerCoreConfig';
import { transformModuleImportsPlugin } from '../plugins/transformModuleImportsPlugin';
import { webSocketsPlugin } from '../web-sockets/webSocketsPlugin';
import { mimeTypesPlugin } from '../plugins/mimeTypesPlugin';
import { Logger } from '../logger/Logger';
import { DevServerCoreConfig } from './DevServerCoreConfig.js';
import { transformModuleImportsPlugin } from '../plugins/transformModuleImportsPlugin.js';
import { webSocketsPlugin } from '../web-sockets/webSocketsPlugin.js';
import { mimeTypesPlugin } from '../plugins/mimeTypesPlugin.js';
import { Logger } from '../logger/Logger.js';

export function addPlugins(logger: Logger, config: DevServerCoreConfig) {
if (!config.plugins) {
Expand Down
22 changes: 11 additions & 11 deletions packages/dev-server-core/src/server/createMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { Middleware } from 'koa';
import koaEtag from 'koa-etag';
import { FSWatcher } from 'chokidar';

import { DevServerCoreConfig } from './DevServerCoreConfig';
import { basePathMiddleware } from '../middleware/basePathMiddleware';
import { etagCacheMiddleware } from '../middleware/etagCacheMiddleware';
import { historyApiFallbackMiddleware } from '../middleware/historyApiFallbackMiddleware';
import { pluginMimeTypeMiddleware } from '../middleware/pluginMimeTypeMiddleware';
import { pluginServeMiddleware } from '../middleware/pluginServeMiddleware';
import { pluginTransformMiddleware } from '../middleware/pluginTransformMiddleware';
import { Logger } from '../logger/Logger';
import { watchServedFilesMiddleware } from '../middleware/watchServedFilesMiddleware';
import { pluginFileParsedMiddleware } from '../middleware/pluginFileParsedMiddleware';
import { serveFilesMiddleware } from '../middleware/serveFilesMiddleware';
import { DevServerCoreConfig } from './DevServerCoreConfig.js';
import { basePathMiddleware } from '../middleware/basePathMiddleware.js';
import { etagCacheMiddleware } from '../middleware/etagCacheMiddleware.js';
import { historyApiFallbackMiddleware } from '../middleware/historyApiFallbackMiddleware.js';
import { pluginMimeTypeMiddleware } from '../middleware/pluginMimeTypeMiddleware.js';
import { pluginServeMiddleware } from '../middleware/pluginServeMiddleware.js';
import { pluginTransformMiddleware } from '../middleware/pluginTransformMiddleware.js';
import { Logger } from '../logger/Logger.js';
import { watchServedFilesMiddleware } from '../middleware/watchServedFilesMiddleware.js';
import { pluginFileParsedMiddleware } from '../middleware/pluginFileParsedMiddleware.js';
import { serveFilesMiddleware } from '../middleware/serveFilesMiddleware.js';

/**
* Creates middlewares based on the given configuration. The middlewares can be
Expand Down
8 changes: 4 additions & 4 deletions packages/dev-server-core/src/server/createServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import http2Server from 'http2';
import fs from 'fs';
import net, { Server, Socket, ListenOptions } from 'net';

import { DevServerCoreConfig } from './DevServerCoreConfig';
import { createMiddleware } from './createMiddleware';
import { Logger } from '../logger/Logger';
import { addPlugins } from './addPlugins';
import { DevServerCoreConfig } from './DevServerCoreConfig.js';
import { createMiddleware } from './createMiddleware.js';
import { Logger } from '../logger/Logger.js';
import { addPlugins } from './addPlugins.js';

/**
* A request handler that returns a 301 HTTP Redirect to the same location as the original
Expand Down
8 changes: 4 additions & 4 deletions packages/dev-server-core/src/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import portfinder from 'portfinder';
import { expect } from 'chai';
import { green, red, yellow } from 'nanocolors';

import { DevServer } from './server/DevServer';
import { DevServerCoreConfig } from './server/DevServerCoreConfig';
import { Logger } from './logger/Logger';
import { Plugin } from './plugins/Plugin';
import { DevServer } from './server/DevServer.js';
import { DevServerCoreConfig } from './server/DevServerCoreConfig.js';
import { Logger } from './logger/Logger.js';
import { Plugin } from './plugins/Plugin.js';

const defaultConfig: Omit<DevServerCoreConfig, 'port' | 'rootDir'> = {
hostname: 'localhost',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Server } from 'net';
import WebSocket from 'ws';
import { EventEmitter } from './EventEmitter';
import { EventEmitter } from './EventEmitter.js';

export const NAME_WEB_SOCKET_IMPORT = '/__web-dev-server__web-socket.js';
export const NAME_WEB_SOCKET_API = 'wds';
Expand Down
4 changes: 2 additions & 2 deletions packages/dev-server-core/src/web-sockets/webSocketsPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Plugin } from '../plugins/Plugin';
import { NAME_WEB_SOCKET_IMPORT, NAME_WEB_SOCKET_API } from './WebSocketsManager';
import { Plugin } from '../plugins/Plugin.js';
import { NAME_WEB_SOCKET_IMPORT, NAME_WEB_SOCKET_API } from './WebSocketsManager.js';
import { appendToDocument, isHtmlFragment } from '@web/parse5-utils';

export const webSocketScript = `<!-- injected by web-dev-server -->
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-server-core/test-helpers.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// this file is autogenerated with the generate-mjs-dts-entrypoints script
export * from './dist/test-helpers';
export * from './dist/test-helpers.js';
4 changes: 2 additions & 2 deletions packages/dev-server-core/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
fetchText,
expectIncludes,
virtualFilesPlugin,
} from '../src/test-helpers';
import { DevServerCoreConfig } from '../src/server/DevServerCoreConfig';
} from '../src/test-helpers.js';
import { DevServerCoreConfig } from '../src/server/DevServerCoreConfig.js';

export function createTestServer(config: Partial<DevServerCoreConfig> = {}) {
return originalCreateTestServer({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';

import { DevServer } from '../../src/server/DevServer';
import { createTestServer } from '../helpers';
import { DevServer } from '../../src/server/DevServer.js';
import { createTestServer } from '../helpers.js';

describe('base path middleware', () => {
describe('without a trailing /', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import path from 'path';
import fs from 'fs';
import { nanoid } from 'nanoid';

import { createTestServer, timeout } from '../helpers';
import { DevServer } from '../../src/server/DevServer';
import { createTestServer, timeout } from '../helpers.js';
import { DevServer } from '../../src/server/DevServer.js';

const fixtureDir = path.resolve(__dirname, '..', 'fixtures', 'basic');
const testFileAName = '/cached-file-a.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { expect } from 'chai';
import path from 'path';

import { createTestServer } from '../helpers';
import { DevServer } from '../../src/server/DevServer';
import { createTestServer } from '../helpers.js';
import { DevServer } from '../../src/server/DevServer.js';

describe('history api fallback middleware', () => {
describe('index in root', () => {
Expand Down
Loading

0 comments on commit 5792e9c

Please sign in to comment.